Page 1 of 1
How to identify a 24bit encoded jpeg but with no real color?
Posted: 2008-07-15T10:34:11-07:00
by dragonv12
I try to identify all images which are scanned from grayscale pages but saved as 24bit images. I tried to count colors but I get :
Code: Select all
- colored page : Colors: 163513
- grayscale page : Colors: 1646
So I don't see any rule I could apply there...
Anyone got an idea ? Eventually I could apply a filter to the images, CPU Time is not an issue
thanks
Re: How to identify a 24bit encoded jpeg but with no real color?
Posted: 2008-07-15T16:02:27-07:00
by fmw42
use:
convert yourimage -resize 1x1! -fx "u.r==u.g&&u.r==u.b?1:0" txt:-
If the image has all three channels the same, you will get a return of 1 or white. If the image has any channel different from the others, you will get 0 or black returned.
You can also try
convert yourimage -format "%[colorspace]" info:-
If the image is grayscale (as IM should recognize that all 3 channels are the same) then it will have colorspace returned as Gray; otherwise RGB
Re: How to identify a 24bit encoded jpeg but with no real color?
Posted: 2008-07-16T00:26:40-07:00
by anthony
JPEG images will never be 'gray' as it is lossy.
However a basic 'grey' test is, to compare the image against
a gray version of itself!
See
http://imagemagick.org/Usage/compare/#type_general
Code: Select all
convert image.jpg \( +clone -colorspace gray \) \
-compose difference -composite \
-format '%[mean]' info:
You can also use '%[maximum]' instead.
Alternative...
Code: Select all
convert image.jpg \( +clone -colorspace gray \) miff:- |
compare -metric PAE - null:
the value given in parenthesis is a normalization of the maximum possible error (1.0 = max)
With the above rose: produced: 41120 (0.627451)
or about 62% error and thus NOT GRAY
while a granite: image produced: 2056 (0.0313725)
or about 3% error and thus may be considered to be GRAY
Re: How to identify a 24bit encoded jpeg but with no real color?
Posted: 2008-07-16T12:25:15-07:00
by dragonv12
I appreciate your help !!
I will try all your solutions and tell which one is most efficient