I have a YCbCr file, I want to force all pixels with Y > 235 to 235 (instead of 255), and force all pixels with Y<16 to 16 (instead of 0)
It is pretty close to what white-threshold and black-threshold do, but I want the white point to be 235 instead of 255, and the black point to be 16 instead of 0.
I could not find a way to do that. Help please!
-white-threshold Force to white all pixels above the threshold while leaving all pixels at or below the threshold unchanged.
-black-threshold Force to black all pixels below the threshold while leaving all pixels at or above the threshold unchanged.
Thanks.
-st
white and black threshold & change white and block value
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: white and black threshold & change white and block value
If you are on Q8 IM, then
convert yimage +level 16,235 new_yimage
if you are on Q16, then you must convert to percent (min=100*16/255 and max=100*235/255)
convert yimage +level min,max% new_yimage
see http://www.imagemagick.org/Usage/color/#level_plus
convert yimage +level 16,235 new_yimage
if you are on Q16, then you must convert to percent (min=100*16/255 and max=100*235/255)
convert yimage +level min,max% new_yimage
see http://www.imagemagick.org/Usage/color/#level_plus
Re: white and black threshold & change white and block value
Thanks for the reply. However I read the exlanations of +level through the link you provided, it does not seem to be what I want.
+level not only modifies the black and white value, it compresses the values in between also.
For my application, I do not want to change the value in between.
I only want to threshold pixels with Y > 235 to 235 (instead of 255), threshold all pixels with Y<16 to 16 (instead of 0), while leave the values in between unchanged. is there a way to do this in IM?
BTW, how do I know if I'm on Q8 IM or Q16 IM? I did a " convert -version", it shows my version is 6.2.4 .
Thanks.
+level not only modifies the black and white value, it compresses the values in between also.
For my application, I do not want to change the value in between.
I only want to threshold pixels with Y > 235 to 235 (instead of 255), threshold all pixels with Y<16 to 16 (instead of 0), while leave the values in between unchanged. is there a way to do this in IM?
BTW, how do I know if I'm on Q8 IM or Q16 IM? I did a " convert -version", it shows my version is 6.2.4 .
Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: white and black threshold & change white and block value
your version 6.2.4 is very old (over 300 versions old). you might consider upgrading. when i do that I get
convert -version
Version: ImageMagick 6.5.9-1 2010-01-16 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
To do what you want, convert your thresholds to percent as mentioned earlier and do the following:
convert image -white-threshold max% -black-threshold min% result
you can also see my script, plm at the link below
convert -version
Version: ImageMagick 6.5.9-1 2010-01-16 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
To do what you want, convert your thresholds to percent as mentioned earlier and do the following:
convert image -white-threshold max% -black-threshold min% result
you can also see my script, plm at the link below