indexing last pixel

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?".
Post Reply
bonobo2000
Posts: 6
Joined: 2011-01-19T13:44:40-07:00
Authentication code: 8675308

indexing last pixel

Post 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
Last edited by bonobo2000 on 2015-07-07T10:02:40-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: indexing last pixel

Post 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
bonobo2000
Posts: 6
Joined: 2011-01-19T13:44:40-07:00
Authentication code: 8675308

Re: indexing last pixel

Post 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...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: indexing last pixel

Post 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.
Post Reply