Page 1 of 1

make all pixels below a certain threshold white? [solved]

Posted: 2017-04-15T20:23:54-07:00
by BradLee
Hi,

I'm trying to make all white pixels below a certain threshold white.
I scanned some pages from a book and there are some not-quite-white pixels, that I want to make true white.

I can do this in another image app by using the wand tool with a 20% threshold, then cutting everything and pasting it onto a clean white page.

But I need to do it on a large number of images, so I am hoping to batch process it with IM instead.

Using ImageMagick-7.0.5-4-Q16-x64-dll.exe In Windows 7.

Kind regards,

Brad

EDIT: Essentially what I am doing is cutting the text off of a page and pasting it onto a white page if that makes more sense.

Re: make all pixels below a certain threshold white?

Posted: 2017-04-15T20:39:48-07:00
by fmw42
Are you sure you do not want to make all pixels above a certain graylevel into white to even out all the (near-) white areas. If that is the case, then try

Code: Select all

magick image -white-threshold XX% result
Where XX% is the percent graylevel value near white. So 80% would make gray(80%) and above into pure white.

If this is not what you want, then please post an example image to some place such as dropbox.com and put the URL here and explain what regions you want white.

Re: make all pixels below a certain threshold white?

Posted: 2017-04-15T21:01:31-07:00
by BradLee
fmw42 wrote: 2017-04-15T20:39:48-07:00 Are you sure you do not want to make all pixels above a certain graylevel into white to even out all the (near-) white areas.
But isn't white 0, and black 255?

Anyhow, your suggestion of this works:

Code: Select all

magick image -white-threshold XX% result
fmw42 wrote: 2017-04-15T20:39:48-07:00 If this is not what you want, then please post an example image to some place such as dropbox.com and put the URL here and explain what regions you want white.
That is what I wanted, thank you.

Re: make all pixels below a certain threshold white?

Posted: 2017-04-15T21:03:30-07:00
by fmw42
But isn't white 0, and black 255?
White is gray(100%) or gray(255) or gray100. Black is gray(0%) or gray(0) or gray0.

Re: make all pixels below a certain threshold white?

Posted: 2017-04-15T21:10:16-07:00
by BradLee
I was referring to absolute white and black, but nevermind it seems that I have mixed the two up.

Black being #000, white being #FFF

Re: make all pixels below a certain threshold white?

Posted: 2017-04-15T21:14:30-07:00
by fmw42
BradLee wrote: 2017-04-15T21:10:16-07:00 I was referring to absolute white and black, but nevermind it seems that I have mixed the two up.

Black being #000, white being #FFF
The above hex values are correct.

Do you mean opacity vs transparency? If you have an alpha channel, white will correspond to fully opaque and black will correspond to fully transparent.

Re: make all pixels below a certain threshold white?

Posted: 2017-04-18T05:24:24-07:00
by BradLee
@fmw42,

As I already explained, I had the white and black values mixed up the wrong way around.
In my mind I thought that WHITE was #000, and BLACK was #FFF