How I could detect all coordinates of points like in this image
How I could detect all coordinates of points like in this image
this is the image
and this is the point
Please help me with this problem
and this is the point
Please help me with this problem
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I could detect all coordinates of points like in this image
What version of IM? On what platform?
The solution is to use "compare" with "-subimage-search".
The solution is to use "compare" with "-subimage-search".
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I could detect all coordinates of points like in this image
You can write to txt: format and exclude the black ones, assuming your image is not jpeg and has solid black for the background.
This works on Unix and lists the coordinates and colors of all non-black pixels. I do not know if Windows has pipes or grep. One of the windows users can corroborate.
Code: Select all
convert image txt:- | grep -v "black"
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I could detect all coordinates of points like in this image
But the required "point" is an image, a subimage.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I could detect all coordinates of points like in this image
Sorry, I misunderstood and did not notice the smaller image. Snibgo's solution is then the correct one. You can then find all the brightest points in the second output image from the subimage-search compare. If on Unix-like systems, see my script maxima.
Re: How I could detect all coordinates of points like in this image
very thankyou; could you send me the link of your script ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I could detect all coordinates of points like in this image
Again I ask: What version of IM? On what platform?
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I could detect all coordinates of points like in this image
Code: Select all
compare -metric RMSE -subimage-search aO4kz.png oe5pC.png x.png
convert x-1.png -define identify:locate=maximum -identify NULL:
Code: Select all
Channel maximum locations:
Gray: 65535 (1) 52,3 52,50 51,81
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I could detect all coordinates of points like in this image
Adding slightly to snibgo reply, you can tell IM how many maxima you want to return using -define identify:limit=X. The default is 3 as he showed. See http://www.imagemagick.org/script/identify.php. However, if the peaks are broad, you can get many values around a single peak. So the better way is to find each, one at a time, then write a small round black area over that maxima. Then search for the next one. I have a bash unix script, maxima, that does that. See my link below.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I could detect all coordinates of points like in this image
The default is to find them all, eg:
In the OP's case, there were only three white pixels.
Code: Select all
f:\web\im>%IM%convert -size 4x4 xc:White -define identify:locate=maximum -identify null:
Channel maximum locations:
Gray: 65535 (1) 0,0 1,0 2,0 3,0 0,1 1,1 2,1 3,1 0,2 1,2 2,2 3,2 0,3 1,3 2,3 3,3
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I could detect all coordinates of points like in this image
I stand corrected. Thanks.
Re: How I could detect all coordinates of points like in this image
very thankyousnibgo wrote: ↑2017-06-04T12:16:23-07:00The output is:Code: Select all
compare -metric RMSE -subimage-search aO4kz.png oe5pC.png x.png convert x-1.png -define identify:locate=maximum -identify NULL:
This gives the three locations of the top-left corner of the location where the subimage is found.Code: Select all
Channel maximum locations: Gray: 65535 (1) 52,3 52,50 51,81