Align Hole Punches

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?".
bwroga
Posts: 9
Joined: 2019-04-27T12:45:45-07:00
Authentication code: 1152

Re: Align Hole Punches

Post by bwroga »

I didn't know that IM had something called connected components, I thought you were just referring to the connected components algorithm in general. That's great.

I think I have a good handle on it. Thanks for your help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Align Hole Punches

Post by snibgo »

"-connected-components" is a fairly new operation, added after this thread was started. It directly gives centroids, so is useful here.

The messy part is finding which components are the ones you want. Perhaps some crop will always find the three holes, and no other dark components. In any case, you might have sanity checks:

- The central hole should be between some limits A and B pixels in area.

- The longer acme holes should be between some limits C and D pixels in area.

- The y-coordinates of all three holes should be roughly equal.

- The distance from both longer holes to the central hole should be roughly equal.

These tests could be done in a script.
snibgo's IM pages: im.snibgo.com
bwroga
Posts: 9
Joined: 2019-04-27T12:45:45-07:00
Authentication code: 1152

Re: Align Hole Punches

Post by bwroga »

snibgo wrote: 2019-04-28T04:29:36-07:00 Can you take it from there? If you need help, I suggest you link to a couple of sample scans.
I got it working! Thanks for your help!
Post Reply