15
$\begingroup$

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.

$\endgroup$
14
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Hehe ... It's not a "classyness" problem. I don't have v9 :) $\endgroup$ – Dr. belisarius Jan 21 '13 at 11:53
13
$\begingroup$

It's actually easier than your linked question, since your ROI is monochromatic!

i1 = Import@"http://i.stack.imgur.com/LKZfw.png"
i2 = Image[ImageData[
   ImageMultiply[Binarize[ColorSeparate[i1, "HSB"][[1]]], i1]] /. {0., 0., 0.} -> {1, 1, 1}]

Mathematica graphics

Edit

If you want a fully saturated image, you could do something like

pmax = Position[ImageData[ColorSeparate[i1, "HSB"][[2]]], 1.][[1]]
Image@Replace[#, Except[{1., 1., 1.}] -> Extract[#, pmax], {2}] &@ ImageData[i2]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ Nice answer (although kind of brevity is the soul of wit ;) ). @M.R if you eventually want to turn the white background (what the verb "remove" implies; at least to me) to transparent please read this contribution of Szabolcs implementing a reverse blend. stackoverflow.com/questions/8041703/… $\endgroup$ – Stefan Jan 21 '13 at 7:37
7
$\begingroup$

In version 10 there is now a RemoveBackground function, with more options and parameters than you could dream of. Without any help, it will do this:

i1 = Import@"http://i.stack.imgur.com/LKZfw.png";
RemoveBackground[i1]

simple remove background

but with some encouragement, in the form of a hint about the background's colour, or some marker positions to indicate the background, it can do even better:

RemoveBackground[i1, {"Background",  {RGBColor[0.9, 0.9, .7], .1}}]

better remove background

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.