Page 1 of 1

How I could detect all coordinates of points like in this image

Posted: 2017-06-01T11:40:47-07:00
by diegomage
this is the image

Image

and this is the point
Image



Please help me with this problem

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-01T15:19:14-07:00
by snibgo
What version of IM? On what platform?

The solution is to use "compare" with "-subimage-search".

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-01T16:51:22-07:00
by fmw42
You can write to txt: format and exclude the black ones, assuming your image is not jpeg and has solid black for the background.

Code: Select all

convert image txt:- | grep -v "black"
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.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-01T17:10:33-07:00
by snibgo
But the required "point" is an image, a subimage.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-01T18:20:11-07:00
by fmw42
snibgo wrote: 2017-06-01T17:10:33-07:00 But the required "point" is an image, a subimage.
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

Posted: 2017-06-04T11:27:53-07:00
by diegomage
fmw42 wrote: 2017-06-01T18:20:11-07:00
snibgo wrote: 2017-06-01T17:10:33-07:00 But the required "point" is an image, a subimage.
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.



very thankyou; could you send me the link of your script ?

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T11:37:28-07:00
by snibgo
Again I ask: What version of IM? On what platform?

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T11:42:11-07:00
by diegomage
snibgo wrote: 2017-06-04T11:37:28-07:00 Again I ask: What version of IM? On what platform?

I use 6.9.8.3
Version: ImageMagick 6.9.8-3 Q16 x86_64
I use linux ubuntu

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T12:16:23-07:00
by snibgo

Code: Select all

compare -metric RMSE -subimage-search aO4kz.png oe5pC.png x.png

convert x-1.png -define identify:locate=maximum -identify NULL:
The output is:

Code: Select all

  Channel maximum locations:
  Gray: 65535 (1) 52,3 52,50 51,81
This gives the three locations of the top-left corner of the location where the subimage is found.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T12:41:20-07:00
by fmw42
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.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T12:58:57-07:00
by snibgo
The default is to find them all, eg:

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
In the OP's case, there were only three white pixels.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T13:29:06-07:00
by fmw42
snibgo wrote: 2017-06-04T12:58:57-07:00 The default is to find them all, eg:
I stand corrected. Thanks.

Re: How I could detect all coordinates of points like in this image

Posted: 2017-06-04T15:20:03-07:00
by diegomage
snibgo wrote: 2017-06-04T12:16:23-07:00

Code: Select all

compare -metric RMSE -subimage-search aO4kz.png oe5pC.png x.png

convert x-1.png -define identify:locate=maximum -identify NULL:
The output is:

Code: Select all

  Channel maximum locations:
  Gray: 65535 (1) 52,3 52,50 51,81
This gives the three locations of the top-left corner of the location where the subimage is found.
very thankyou