annoying failure with thresholding

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
magiotrope
Posts: 11
Joined: 2012-03-19T06:05:50-07:00
Authentication code: 8675308

annoying failure with thresholding

Post by magiotrope » 2012-06-07T07:33:11-07:00

This might be a general imagemagick issue rather than perl-specific, but I'm using perl (and command-line convert)

So far, imagemagick thresholding is, at best, flaky for me, or even downright useless. Gimp's Colors->Threshold removes light-gray fuzz from my image, leaving just black and white pixels, with its default value of 127 (of max 255).

It would seem that

convert 50% in.jpg out.jpg

or

convert 32768 in.jpg out.jpg

or

$image->Threshold(threshold=>'50%')

would achieve the same thing -- remove the fuzz. But none of the above three are removing the fuzz.

I've also played with -white-threshold and -black-threshold, and it's just ineffective, for the stated objective.

Any suggestions?

thanks

User avatar
fmw42
Posts: 24942
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: annoying failure with thresholding

Post by fmw42 » 2012-06-07T09:07:52-07:00

convert 50% in.jpg out.jpg
I do not use or know perl, but the above in not correct. It should be

convert in.jpg -threshold 50% out.jpg

magiotrope
Posts: 11
Joined: 2012-03-19T06:05:50-07:00
Authentication code: 8675308

Re: annoying failure with thresholding

Post by magiotrope » 2012-06-07T15:21:26-07:00

fmw42 wrote:
convert 50% in.jpg out.jpg
I do not use or know perl, but the above in not correct. It should be

convert in.jpg -threshold 50% out.jpg
yup, sorry -- that was a typo on my part. I have been trying it with the CORRECT syntax, like the one you spelled out. What I said originally still stands -- the imagemagick thresholding does not remove light-gray fuzz. But the Gimp threshold DOES.

thanks

User avatar
fmw42
Posts: 24942
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: annoying failure with thresholding

Post by fmw42 » 2012-06-07T16:17:06-07:00

can you provide a link to your image?

and tell us exactly what your command line is and what version of IM and platform you are using?

magiotrope
Posts: 11
Joined: 2012-03-19T06:05:50-07:00
Authentication code: 8675308

Re: annoying failure with thresholding [SOLVED]

Post by magiotrope » 2012-06-09T00:27:32-07:00

fmw42 wrote:can you provide a link to your image?

and tell us exactly what your command line is and what version of IM and platform you are using?
I solved my problem. It was the destination format. Duh! I was thresholding the original image and then saving it back to a jpg, with default compression quality that was re-introducing my gray pixelation !

Two possible solutions, so far: make the destination format PBM or similar, or use 100% quality for the jpeg:

1) convert -threshold 50% in.jpg out.pbm

2) convert -threshold 50% -quality 100% in.jpg out.jpg

Both of the above work!

Haven't tried perlmagick, but am assuming it will work (if not, I'll post my rants here ;-))

Post Reply