Page 1 of 1

indexing last pixel

Posted: 2015-07-06T15:49:33-07:00
by bonobo2000
hi,
I would like to use

Code: Select all

-floodfill -0-0

command and use the last pixel (pixel located at the last column, last row) as seed in a batch of 10^6 images.
I am wondering how I could achieve this afar?

Machine: OSX 10.9
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-12-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps tiff webp x xml zlib

thx

Re: indexing last pixel

Posted: 2015-07-06T16:24:17-07:00
by fmw42
What is your IM version and platform?

You can also use -fill somecolor -draw "color x,y floodfill"

To get the last coordinate in the image, use

Code: Select all

convert image -format "+%[fx:w-1]+%[fx:h-1]" info:
That will give you the +X+Y coordinate of the bottom right pixel in the image.

If you use -draw, I think it respects the -gravity, so you could do

Code: Select all

convert image -fill somecolor -gravity southeast -draw "color 0,0 floodfill" result
and it will use the bottom right corner pixels.


see
http://www.imagemagick.org/Usage/draw/#color

Re: indexing last pixel

Posted: 2015-07-06T16:52:41-07:00
by bonobo2000
thx a lot for your reply, the info is added in the initial post.

basically what I am trying to do is to floodfill using the four corners as seed and the actual color values of these pixels as the color value.
if somebody could give me a nice simple example, it would save me considerable amount of time...

Re: indexing last pixel

Posted: 2015-07-06T17:06:10-07:00
by fmw42
You do not say what platform! Syntax may different on Windows from Unix. If you floodfill from each corner you will get 4 results. What do you want to do with them afterwards? You will also need to provide a -fuzz value. If -fuzz 0, then you will get no change since any neighboring values that are the same will stay that way and any other similar colors will be unchanged.

What is the purpose of your floodfill process? What is the end goal?

Can you upload an example image to some place such as dropbox.com and put the URL here, so we can test and understand what you want to do better?

Whether you use -floodfill or -draw, you still need to provide the fill color. So you must extract it first from the image corner. To do the bottom right corner, this would be the way in Unix.

Code: Select all

cornercolor=`convert image -gravity southeast -format "%[pixel:u.p{0,0}]" info:`
convert image -fuzz XX% -fill "$cornercolor" -gravity southeast -draw "color 0,0 floodfill" resultimage
where XX% is your fuzz value for determining how similar the colors should be to the corner color to do the floodfill.