Skip to main content

How to remove constant background from an image?


I'm not sure how to remove the paper background from this logo with v9.


enter image description here


This is really not the same as this question, but I think similar methods apply.



Answer



Not as classy as @belisarius', but:


i1 = Import@"http://i.stack.imgur.com/LKZfw.png"

ColorReplace[i1, RGBColor@PixelValue[i1, {2, 2}], .02]

logo


Edit:


Perhaps it would be better would be to use Vitaliy's method, illustrated in this excellent answer. In this version, the image has a white background, not transparent (hence the difference in color, I suppose):


data = ImageData[i1];
Image[data /. {x_, y_, z_} /;
EuclideanDistance[{x, y, z}, data[[2, 2]]] < .3 -> {1, 1, 1}]

logo2



The value of .3 is taken from looking at a ListPlot of the EuclideanDistance values.


Comments