Mathematica Asked by LCarvalho on May 16, 2021
Daily I make an image composition with background (background) in alpha channel in the following dimensions: 558px (length) and 465px (height)
background=Import["https://i.stack.imgur.com/TWwdW.png"];
I always have an image with pixels left over that I want to insert in the lower left corner of the image that I usually call img1:
img1=Import["https://i.stack.imgur.com/hSNbn.png"];
I always have an image with pixels left over that I want to insert in the upper left corner of the image that I usually call img2:
Usually, both images are larger than the area of the final image (background). And I eliminate the background and do a better framing.
img1Fit=ImageCrop[RemoveBackground[img1,White]];
img2Fit=ImageCrop[RemoveBackground[img2,White]];
I’m trying to make the bottom layer the image "background" file.
The second layer is the img1Fit file in the lower left corner.
And the third layer is the img2Fit file in the upper right corner.
So that the images img1Fit and img2Fit do not overlap and can be resized so that they are in the background.
I tried a code, but it didn’t work …
finalImage=ImageCompose[background,{ImageResize[img1Fit,{232}],ImageResize[img2Fit,{232}]},{{Left,Bottom},{Right,Top}}]
Expected result (something similar):
Another important information is that the "finalImage" has AlphaChannel = True.
Use
and
Show[backgr, img1Fit]
This is a Graphics
object and can be saved to image formats i. e. by Export
.
img1Fit is already cropped and transparent.
Show aligns the size and is able to use different formats of images.
The built-in of choice is
Overlay[{Graphics[{Disk[]}], Slider2D[]}, All, 2, Alignment -> Center]
Transparency with Overlay:
Overlay[{ExampleData[{"TestImage", "Clock"}],
Plot[Cos[x], {x, 0, 6},
Background -> Directive[{Opacity[0.5], LightOrange}]]},
Alignment -> Center]
It is possible to use Overlay
in Manipulate
and position and mix images interactively.
The last of the requirements is independent of the rest because Mathematica has a built-in AlphaChannel
. Before exporting this built-in can be applied. This too works with 2D and 3D objects designed in Mathematica.
I am using Version 12.0.0.!
I did not receive img2 nor can I derive img2Fit but I was able to do with the variation:
finalImage =
ImageCompose[
backgr, {ImageResize[img1Fit, {232}],
ImageResize[img1Fit, {232}]}, {{Left, Bottom}, {Right, Top}}]
SetAlphaChannel[i, ColorNegate[a]]
SetAlphaChannel[finalImage, ColorNegate[a]]
The problem is that the image is White and only a mask with overlay remains after the negation is processed.
ColorNegate[finalImage]
SetAlphaChannel[finalImage]
Most interest in AlphaChannel intent to use Adobe products. Google finds a vast amount of community discussion about that topic:
problem AlphaChannel
photoshop.
It is well known that Mathematica is somewhat cheap in images. For example if to attempt to upload a sized image output from Mathematica via Export into the Adobe graphics and foto community, Mathematica fails. I expect so that it is the very same with AlphaChannel
. Mathematica gains input and advances from libraries that have advantages and disadvantages. This is the same with nearly all other programs offering AlphaChannel
. So this can be taken as the sole property behavior of Adobe.
So the workaround of recommendation might be Adobe Capture. But for hard insider, this seems to depend on the license set installed on Your workstation, whether this has impact on the Adobe alpha channel. But Your question is not that detailled. Lost cost can be the idea to save the output into a pdf. Open that in Adobe Acrobat Reader and use the screenshot function in the menu Edit>Take a Snapshot.
If You stay inside the Mathematica influence program sphere this might pose the desired result, but to the Python sphere this might be different and fail.
Correct answer by Steffen Jaeschke on May 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP