[magick-users] Counting and differing pixels transparent and non-transparent
Anthony Thyssen
A.Thyssen at griffith.edu.au
Sun Sep 27 16:59:29 PDT 2009
On Thu, 24 Sep 2009 15:06:44 -0700
Fred Weinhaus <fmw at alink.net> wrote:
| 1) extract the alpha channel (presumably as a binary image) white as
| opaque and black as transparent
|
| convert image -alpha extract alphachannel.png
|
| 2) in a loop extract each column (see subsectioning
| [1xheight+xoffset+0] or -crop ... +repage) and sequence down the
| column (y increases downward in pixels) until you find the first
| pixel that is white -- that will be the highest (closest to the top)
| non-transparent pixel in the column.
|
| 3) repeat for each column
|
| 4) compare the results from each column to find the one that is closest to y=0
|
Fast way... extract the alpha channel, trim, and report the results virtual
canvas!
convert image -alpha extract -trim -format '%wx%h%O' info:
This give you the size, and top left corner offset of the non-transparent
parts of the image.
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
Oh they never lie. They dissemble, evade, prevericate, confound, confuse,
distract, obsure, subtly mis-represent, and wilfully misunderstand...,
but they never lie. Perish The thought. - about Mind Ships of Culture
-- Iain M. Banks, "Look to Windward"
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
More information about the Magick-users
mailing list