Point picker GUI under Windows?

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?".
Locked
User avatar
whugemann
Posts: 313
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Point picker GUI under Windows?

Post by whugemann »

This might be a little bit off topic, but could you think of a suitable GUI that could run a Windows cmd-Script or alike, providing it with a file with pixel coordinates?

The question arises in the context of a recently written script that rectifies photographs by means of IM's -distort perspective. Besides other information, the user has to provide the image coordinates of four match points, which they have to determine in advance and have to note on an piece of paper.

So far, I know of (and have used) the following approaches:
  • Get the current rectangular selection from IrfanView's title bar.
  • Get real coordinates 0 .. 1 from a Winmorph file.
  • Generate point lists with Fiji (ImageJ)
whick are either not appropriate (first one) or too laborious for the user in the case of just four points.

Any other ideas over here?
Could I possibly ask the user to mark the pixels with a certain colour and then get the coordinates of these pixels with IM?
Wolfgang Hugemann

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Point picker GUI under Windows?

Post by snibgo »

whugemann wrote:Could I possibly ask the user to mark the pixels with a certain colour and then get the coordinates of these pixels with IM?
That's the easy way. Your script makes a copy of the image ensuring that it has no pixels that are exactly (say) red. Then it fires up Gimp (or any image editor) with that image. The user makes four pixels red, saves the file and exits Gimp. The script then finds the four red pixels. If there are not exactly four, it raises an error.
snibgo's IM pages: im.snibgo.com

User avatar
whugemann
Posts: 313
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Point picker GUI under Windows?

Post by whugemann »

snibgo wrote:
2019-12-21T09:00:04-07:00
The script then finds the four red pixels.
Well, could you make a suggestion how this could actually be done? How can I get IM to spit out the coordinates of the four red pixels to the console or a text file?
Wolfgang Hugemann

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Point picker GUI under Windows?

Post by snibgo »

Make non-red pixels transparent, and write to "sparse-color:".
snibgo's IM pages: im.snibgo.com

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

Re: Point picker GUI under Windows?

Post by fmw42 »

Make everything in your image that is not red (points) into transparent and then use sparse-color: to extract the colors or txt: and pipe to grep

Here are examples.

# make a transparent image with some red in it
convert -size 100x100 xc:none -size 3x3 xc:red -composite x.png

Code: Select all

convert x.png sparse-color:
0,0,srgba(255,0,0,1) 1,0,srgba(255,0,0,1) 2,0,srgba(255,0,0,1) 0,1,srgba(255,0,0,1) 1,1,srgba(255,0,0,1) 2,1,srgba(255,0,0,1) 0,2,srgba(255,0,0,1) 1,2,srgba(255,0,0,1) 2,2,srgba(255,0,0,1) 

Code: Select all

convert x.png txt: | grep -v none
# ImageMagick pixel enumeration: 100,100,65535,srgba
0,0: (65535,0,0,65535)  #FF0000FF  red
1,0: (65535,0,0,65535)  #FF0000FF  red
2,0: (65535,0,0,65535)  #FF0000FF  red
0,1: (65535,0,0,65535)  #FF0000FF  red
1,1: (65535,0,0,65535)  #FF0000FF  red
2,1: (65535,0,0,65535)  #FF0000FF  red
0,2: (65535,0,0,65535)  #FF0000FF  red
1,2: (65535,0,0,65535)  #FF0000FF  red
2,2: (65535,0,0,65535)  #FF0000FF  red
You might also look into the pointpicker extension to ImageJ, which is available for Linux, Mac OSX and Windows. It will save a file of points.

User avatar
whugemann
Posts: 313
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Point picker GUI under Windows?

Post by whugemann »

Thanks, the decisive hint was the sparse-color: format, which I didn't know of.

In order to make the point marker extraction reliable in a JPEG environment, I would have to make the user draw larger dots. Which is fine, as these can be seen more easily on a large photo. After applying the +transparent operator with some fuzz, I would then have to apply a morphology on these dots to reduce each of them to just one pixel. I studied Anthony's page on the Morphology of Shapes, but couldn't figure out a solution for that. I am sure there is a solution for that (?).
Wolfgang Hugemann

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Point picker GUI under Windows?

Post by snibgo »

snibgo wrote:Your script makes a copy of the image ensuring that it has no pixels that are exactly (say) red. Then it fires up Gimp (or any image editor) with that image. The user makes four pixels red, saves the file and exits Gimp. The script then finds the four red pixels.
Use a lossless format for this. If you use a lossy format such a JPEG, you can't guarantee that is starts with no red pixels, or that the pixels set to red by the user remain red.

To reduce multiple white areas to a single point each:

Code: Select all

magick  in.png -morphology Distance Euclidean:"4,1" -auto-level -morphology HMT Peaks:4.5,5.3 -morphology HMT Peaks:1 -auto-level -threshold 0 out.png
EDIT: Or you might use "-connected-components" and use the centre of each bounding box.
snibgo's IM pages: im.snibgo.com

Locked