Page 1 of 1
color tracking
Posted: 2011-02-23T08:39:04-07:00
by Darkout
Hi guys,
How can i do a '
color tracking' (means detect/locate a specific color in an image) using ImageMagick. Solutions on command-line or Magick++ or MagickWand for C can be very helpful for me.
Thanking you in advance,
I am a newbie
Re: color tracking
Posted: 2011-02-23T11:21:04-07:00
by fmw42
convert your color to transparent, then send the output to txt: and run grep or sed to filter only those lines that have your transparent color. the first part of each line will be the coordinates
convert logo: -depth 8 logo.png
convert logo: -transparent "rgb(255,0,0)" txt:- | grep "rgba(255,0,0,0)"
244,38: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
237,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
238,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
239,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
240,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
...
Re: color tracking
Posted: 2011-02-23T19:30:40-07:00
by anthony
Re: color tracking
Posted: 2011-02-24T12:39:17-07:00
by Darkout
Good evening,
Thanks fmw42 for your answer. It seems to me very interesting
Thanks anthony that's what i've been looking for, by introducing this fuzzy tolerance i'll detect perfectly my colored object.
I'll test this on command line tool first then i'll implement this in a C/C++ or java code.
Re: color tracking
Posted: 2011-02-24T15:44:36-07:00
by fmw42
Darkout wrote:Good evening,
Thanks fmw42 for your answer. It seems to me very interesting
Thanks anthony that's what i've been looking for, by introducing this fuzzy tolerance i'll detect perfectly my colored object.
I'll test this on command line tool first then i'll implement this in a C/C++ or java code.
I would have included the -fuzz in my suggestion, but you said you wanted a "
specific color"
Re: color tracking
Posted: 2011-02-24T15:56:18-07:00
by Darkout
Yes that's right! i didn't specify that i'm working on true colors
thank you!
by the way it works fine on command line
i should make an intelligent code in a way to adjust the fuzz value depending on the the image luminance and contrast.
Re: color tracking
Posted: 2011-02-27T10:28:29-07:00
by Darkout
fmw42 wrote:convert your color to transparent, then send the output to txt: and run grep or sed to filter only those lines that have your transparent color. the first part of each line will be the coordinates
convert logo: -depth 8 logo.png
convert logo: -transparent "rgb(255,0,0)" txt:- | grep "rgba(255,0,0,0)"
244,38: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
237,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
238,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
239,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
240,39: (255, 0, 0, 0) #FF000000 rgba(255,0,0,0)
...
Hello,
How can i implement this on MagickWand or Magick++ (C/C++) or JMagick
Is there a tutorial to use IM convert programme in those programming tools?
thanks
Re: color tracking
Posted: 2011-02-27T16:02:42-07:00
by anthony
In MagickWand or Magic++, you are better off finding one of the 'loop though pixel example demo programs, and then looking at the pixels directly yourself.
Command line shell does not have that luxury (though it can do it with a -fx expression) and uses text processing tools on identify output. It is slower but it gets the job done.
Re: color tracking
Posted: 2011-03-02T19:08:13-07:00
by Darkout
anthony wrote:In MagickWand or Magic++, you are better off finding one of the 'loop though pixel example demo programs, and then looking at the pixels directly yourself.
Command line shell does not have that luxury (though it can do it with a -fx expression) and uses text processing tools on identify output. It is slower but it gets the job done.
can you explain a little bit more your contribution!
did you meant that i should code in C instead of using MagickWand
and please tell me what MagickWand can offer to users?
Thanks anthony
Re: color tracking
Posted: 2011-03-02T19:29:18-07:00
by anthony
there should be some same code for this.
I myself don't program in magick wand, but looping through the pixels in an image is a standard thing.
Check the documentation for MagickWand.