Page 1 of 1
Finding corner pixels in multiple images
Posted: 2015-09-27T20:41:53-07:00
by miguellint
Hello...
In an earlier thread I found the following reply...
Try -fuzz 1% -fill black -floodfill +0+0 white
and repeat the flood fill on each corner pixel.
viewtopic.php?t=17659#p66613
How do I find each corner pixel when I have multiple images of varying sizes.
I was trying to use gravity (NorthEast, SouthEast, SouthWest) but was unsuccessful.
I think I need something to find width-1 and height-1
Advice appreciated.
Many thanks
Miguel
Re: Finding corner pixels in multiple images
Posted: 2015-09-27T23:01:15-07:00
by fmw42
use -gravity with
Code: Select all
-gravity XX -fuzz 1% -fill black -draw "color 0,0 floodfill"
Re: Finding corner pixels in multiple images
Posted: 2015-09-27T23:48:56-07:00
by miguellint
Hello Fred...
Thank you for the reply.
The command you gave was the same command I thought would do the trick but no matter which gravity I try the floodfill always starts in the NorthWest corner.
Here is a link to a stock image of a black diamond. The link is on Dropbox so just X the Register/Sign-In pop-up.
http://tinyurl.com/qcoz6ul
All I'm trying to do is black floodfill the SouthEast corner. Then I'd like to use the same command on identical images but of varying sizes.
The following command simply fills the NorthWest corner, not the SouthEast corner as expected.
Code: Select all
convert black_diamond.jpg -gravity SouthEast -fuzz 1% -fill black -draw "color 0,0 floodfill" black_diamond_filled.jpg
I can sort of make it work if I include a -region but that seems to be a bit of a kludge.
It's just a learning exercise at the moment but I'll eventually need a gravity/floodfill command for several hundred scans I need to tidy up. It would be nice if I understood what I was doing and not just copy/paste
Thanks again
Miguel
Re: Finding corner pixels in multiple images
Posted: 2015-09-28T09:40:40-07:00
by fmw42
I can verify. This would appear to be a bug. I will report it. A workaround is to rotate the image 180 deg, do the floodfill, then rotate (back) by 180. Or extract the southwest corner coordinates in a prior command and store as a variable. For example
Code: Select all
convert black_diamond.jpg -rotate 180 -fuzz 10% -fill black \
-draw "color 0,0 floodfill" -rotate 180 black_diamond_filled.jpg
or in unix format
Code: Select all
coords=`convert black_diamond.jpg -format "%[fx:w-1],%[fx:h-1]" info:`
convert black_diamond.jpg -fuzz 10% -fill black \
-draw "color $coords floodfill" black_diamond_filled.jpg
P.S In the future, please always provide your version of IM and platform.
Re: Finding corner pixels in multiple images
Posted: 2015-09-28T19:28:01-07:00
by miguellint
Hello Fred...
Thanks once again for taking the time to reply.
Your rotation work-around is quite clever but your Unix solution is absolutely perfect
Thanks again
Miguel
IM 6.8.9-9
Kubuntu 15.04 (better late than never)