how to find highest color ?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
paolob

how to find highest color ?

Post by paolob »

how to find highest color in a image ?
I use ImageMagickObject.MagickImage

Set I = CreateObject("ImageMagickObject.MagickImage.1")
ret = I.Convert( image, "-format", "%c", "histogram:info:-" )
but this not work

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

Re: how to find highest color ?

Post by fmw42 »

I do not know how to do this in your API, but in the command line:

convert image -format "%[fx:maxima]" info:

will give you the max value in the range of 0 to 1. This is an fx calculation


or

convert image -format "%[max]" info:

will give you the max in the range of 0 to QuantumRange for your IM compile. For Q8 QR=255, for Q16 QR=65535. This is a string format.


See

http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/script/escape.php
paolob

Re: how to find highest color ?

Post by paolob »

No
I want the highest color in the image, no the possible highest ...
in my image the highest color is 252,192,168

es.:
convert CF_prova.bmp -format "%%[fx:p{10,20}.r*255]" info:-
so I have red component for pixel al 10,20
but I want to see all points end find the the top rer, top green, and top blue componet
;-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to find highest color ?

Post by fmw42 »

OK. Sorry I misunderstood.

But what does top color mean?

Is that the one most frequently found in the histogram?

If not, then you cannot have a top color for all 3 of R,G,B simultaneously that corresponds necessarily to any pixel in the image. You can find the brightest values in each channel (but there may be no pixel in the image with that combination).

Or you can find the colors corresponding to the brightest value in HSL or HSB space using the largest value in L or B, but that could correspond to many different combinations of R,G,B.

So please clarify what you mean by top color?

And if the one most frequent in the histogram, then do you want to see where they all are in the image or just know the color?

If you only want to know the most frequently used color from the histogram:

convert rose: -format "%c" histogram:info: | sort -r -k 1 | head -n 1
21: (255,255,255) #FFFFFF white
Post Reply