# remove transparency of background Image

I have the following image:

As you can see the background is kind of white-ish. Now my question is: How can I remove this transperancy of the background image ?

• What do you mean by "transparency"? The image seems to have no alpha channel... – J. M.'s ennui Nov 13 '17 at 12:38
• @J.M. I would like to make the image background as "sharp" as the foreground. Basically I mean by "transparency" the fact that the background looks like one took the original slide and increased the transparency, then placed the speaker in front. – james Nov 13 '17 at 12:46

If a pixel is part of the transparent slide on white color all channels will have a high value. The code below checks which pixels have a channel whose value is less than tol and extents the set with some radius. The complement set to the found pixels are assumed to be the background.

tol = 0.6;

(*background pixel positions*)
pos = Complement[Tuples[Range /@ ImageDimensions[im][[{2, 1}]]],
Clip[Map[Min, ImageData[im], {2}], {tol, tol}, {0, 1}], 0.], 1]];


The smallest channel value indicates how transparent the background is.

r = Min@Extract[ImageData[im], pos];


Cancel transparency:

Image[MapAt[(# - {r, r, r})/(1 - r) &, ImageData[im], pos]]


• Awesome answer ! Thanks a lot ! :) – james Nov 13 '17 at 15:53