Searching images by its colors
Searching images by its colors
Hi:
I have seen a similar question posted but not exactelly what I want.
I would like to order some images by the ammount of a wanted color especified
I feel the color should be a range of that color for example more or less "red"
So if I have a set of fruits and I ask the amount of RED they have and I order the result
I shoulds see first the tomatoes, cheries and rasperies, then maybe apples, oranges, and advocados.
Can I have a suggestion on how to extract form a image the percetage (or bits) of a certain
color?
Any Idea would be appreciated.
Emilio
I have seen a similar question posted but not exactelly what I want.
I would like to order some images by the ammount of a wanted color especified
I feel the color should be a range of that color for example more or less "red"
So if I have a set of fruits and I ask the amount of RED they have and I order the result
I shoulds see first the tomatoes, cheries and rasperies, then maybe apples, oranges, and advocados.
Can I have a suggestion on how to extract form a image the percetage (or bits) of a certain
color?
Any Idea would be appreciated.
Emilio
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Searching images by its colors
try
where XX% is the percent similar to red and the rest will be made black. Choose your XX% as desired and make the color after +opaque as close to the desired color as you want.
Alternately, just extract the red channel of the image and get its mean value
Code: Select all
convert image -fuzz XX% -fill black +opaque red -format "%[fx:100*mean]" info:
Alternately, just extract the red channel of the image and get its mean value
Code: Select all
convert image -channel r -separate +channel -format "%[fx:100*mean]" info:
Re: Searching images by its colors
fmw42:
Thanks for the help...
But my knowledge is limited and I do not get anything..
I have tried this:
run convert foto.jpg -fuzz 10% -fill black +opaque red -format "%[fx:100*mean]" info:
The process SEEMS to go ok, but I do not get any results...
I feel the info: means somethig but really I do not know where to get it
Thanks
Emilio
Thanks for the help...
But my knowledge is limited and I do not get anything..
I have tried this:
run convert foto.jpg -fuzz 10% -fill black +opaque red -format "%[fx:100*mean]" info:
The process SEEMS to go ok, but I do not get any results...
I feel the info: means somethig but really I do not know where to get it
Thanks
Emilio
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Searching images by its colors
What platform? Microsoft Windows?
If so, do not use "run". Simply type the command at the command prompt, in the command window:
If so, do not use "run". Simply type the command at the command prompt, in the command window:
Code: Select all
convert foto.jpg -fuzz 10% -fill black +opaque red -format "%[fx:100*mean]" info:
snibgo's IM pages: im.snibgo.com
Re: Searching images by its colors
snibgo:
Sorry sometimes I forget that I should put the OS I am using...
Yes I am using Microsoft windows 7
Thaks
Emilio
Sorry sometimes I forget that I should put the OS I am using...
Yes I am using Microsoft windows 7
Thaks
Emilio
Re: Searching images by its colors
fmw42 and snibgo:
Yes I tried at the command line DOS, and it worked...
Still I need it to work it from dBASE PLUS (I have to use the RUN)
So I tried again and now it works ... magick
RUN convert FOTO.JPG -fuzz 100% -fill black +opaque red -format "%[fx:100*mean]" info: > aaa.txt
modi comm aaa.txt
I get the result on the aaa.txt file and in this case I get about 50.000
I do not know what this means but I am going to work on it...
Thanks again
Emilio
Yes I tried at the command line DOS, and it worked...
Still I need it to work it from dBASE PLUS (I have to use the RUN)
So I tried again and now it works ... magick
RUN convert FOTO.JPG -fuzz 100% -fill black +opaque red -format "%[fx:100*mean]" info: > aaa.txt
modi comm aaa.txt
I get the result on the aaa.txt file and in this case I get about 50.000
I do not know what this means but I am going to work on it...
Thanks again
Emilio
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Searching images by its colors
It means 50% red, if I read your 50.000 correctly. But using -fuzz 100%, is not advised, since it will catch all colors in the image and should return a very large value close to 100%. You should use a relatively small XX% so that you get only colors close to your specified color red. This command may not be what you want, since it is very color specific. You may get a better result from my second command looking at the mean of the red channel?
Re: Searching images by its colors
fmw42:
Yes the first line does not get sound results I tried the second one.
convert image -channel r -separate +channel -format "%[fx:100*mean]" info:
Image with quite a lot of whites 40% and some black 20% bluesky 40%
r= 50.6102
b= 62.7957
g= 55.5145
Image of red pepers red 70% green 10% white+black 20%
r= 74.445564.7145
b= 7.388986.53545
g= 17.264515.1312
1) I assume r= red, b=blue, g=green ... what other combination I get available?
2) 74.445564.7145 Is this a real number?
Thaks a lot
Emilio
Yes the first line does not get sound results I tried the second one.
convert image -channel r -separate +channel -format "%[fx:100*mean]" info:
Image with quite a lot of whites 40% and some black 20% bluesky 40%
r= 50.6102
b= 62.7957
g= 55.5145
Image of red pepers red 70% green 10% white+black 20%
r= 74.445564.7145
b= 7.388986.53545
g= 17.264515.1312
1) I assume r= red, b=blue, g=green ... what other combination I get available?
2) 74.445564.7145 Is this a real number?
Thaks a lot
Emilio
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Searching images by its colors
First, the command I gave should not give out more than one value (for the red channel). Nevertheless, this command will not work well if the image has lots of white, because white has equal parts of r,g,b, so the mean of r will be large. For example, using the two IM internal images, logo: and rose:. logo: has lots of white and a small percentage of red, but rose: has lots of red and little white.
89.9307
57.142
So my concept of using just the red channel is flawed. But perhaps using the ratio of the red to the average of the green and blue channel will be better. The larger the ratio, the more reddish the image is. For example
171.7
100.739
Code: Select all
convert logo: -channel r -separate +channel -format "%[fx:100*mean]" info:
Code: Select all
convert rose: -channel r -separate l -format "%[fx:100*mean]" info:
So my concept of using just the red channel is flawed. But perhaps using the ratio of the red to the average of the green and blue channel will be better. The larger the ratio, the more reddish the image is. For example
Code: Select all
convert rose: -format "%[fx:100*mean.r/((mean.g+mean.b)/2)]" info:
Code: Select all
convert logo: -format "%[fx:100*mean.r/((mean.g+mean.b)/2)]" info:
Re: Searching images by its colors
fmw43:
I have used this one and the results are very acceptable.
To my eyes perception I feel that the results are acordingly to
the red I see on the image.
convert logo: -format "%[fx:100*mean.r/((mean.g+mean.b)/2)]" info:
Still this is more that I can chew...
I would not like to impose more of your time, but in order for me to continue
I have some doubts.
1) I have tried with .TIF, and it is not acceptable (not a problem just to be sure)
2) this results are ok for red, but lets say that I should offer 10 colors
r, g, b and brow, yellow, black, white etc
what would be the logic of this?
Thanks
Emilio
I have used this one and the results are very acceptable.
To my eyes perception I feel that the results are acordingly to
the red I see on the image.
convert logo: -format "%[fx:100*mean.r/((mean.g+mean.b)/2)]" info:
Still this is more that I can chew...
I would not like to impose more of your time, but in order for me to continue
I have some doubts.
1) I have tried with .TIF, and it is not acceptable (not a problem just to be sure)
2) this results are ok for red, but lets say that I should offer 10 colors
r, g, b and brow, yellow, black, white etc
what would be the logic of this?
Thanks
Emilio
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Searching images by its colors
My method only works for red or green or blue, because those are the only channels in an RGB image. You could also make it work for cyan, magenta, yellow or black, by converting the image from RGB to CMYK using -colorspace CMYK or using profiles for RGB and for CMYK. But it will not work for any arbitrary color. For that you would need to go back to my original command and specify some value for -fuzz XX% that is an acceptable amount of closeness to your specified color. For example 10% would find all colors that are within 10% of the specified color and give you the percentage of that color in the image.
I have no idea why it does not work for TIFF files for red. It should not matter what image format is being used. It is only content dependent.
I have no idea why it does not work for TIFF files for red. It should not matter what image format is being used. It is only content dependent.
Re: Searching images by its colors
fmw42:
Thanks for all.
I will start working with 3 colors and
see how it comes.
Then I will try your other options.
Emilio
Thanks for all.
I will start working with 3 colors and
see how it comes.
Then I will try your other options.
Emilio