Let's take a sample image
Now I want to make transparent all the white areas of the image, so as to be able to copy/paste it above text
After the copy/paste only the color parts (non-white) of the figure should be covering the text.
I use version 9.0 of Mathematica.
Any suggestions?
img = Import["https://i.stack.imgur.com/JLncI.png"]
,Export["transparent.png", SetAlphaChannel[img, 1 - ColorSeparate[img][[1]]]]
seems to work. But it's not going to be generalizable to more complex images... Although, having just seen @C.E.'s answer,RemoveBackground
seems like the right way to go in this case. $\endgroup$ – aardvark2012 Nov 26 '17 at 11:11SetAlphaChannel::invalpha: Expecting an image or a number between 0 and 1 for the alpha channel specification instead of 1
$\endgroup$ – Vaggelis_Z Nov 26 '17 at 11:221 - ColorSeparate[img][[1]]
give you? It gives me an image that I use as a mask... albeit a pretty hacky one. $\endgroup$ – aardvark2012 Nov 26 '17 at 11:371 - ColorSeparate[img][[1]]
I get 1 - the image in black and white. $\endgroup$ – Vaggelis_Z Nov 26 '17 at 11:41SetAlphaChannel
should be using that image as the mask... no idea what's going on there and why the error is appearing (it doesn't for me). ButRemoveBackground
seems to be working for you now, so I'd stick with that. $\endgroup$ – aardvark2012 Nov 26 '17 at 11:45