Page 1 of 1

I need a faster way to generate locations of white pixels

Posted: 2013-09-29T12:16:56-07:00
by dgpeters
I need to display the locations of all the white pixels in my monochrome PNG file (i.e., identify reports it as: trythis3.png PNG 769x550 769x550+0+0 8-bit sRGB 2c 6.14KB 0.000u 0:00.000). I've got something that works: "convert trythis3.png sparse-color:- | tr ' ' '\n' | grep white" but I find it to take about 3 seconds per file which I think is slower than it needs to be. I read somewhere that there is a preferred (and faster) way to generate the information but I can't remember the other method. Basically I need the X,Y locations of all the white pixels. Like this:

10,11
12,13
1500,2021

Once again thanks to the author of this spectacular program.

Re: I need a faster way to generate locations of white pixel

Posted: 2013-09-29T12:28:11-07:00
by snibgo
Make everything other than white transparent first. See viewtopic.php?f=1&t=24095

Re: I need a faster way to generate locations of white pixel

Posted: 2013-09-29T13:11:48-07:00
by fmw42
snibgo wrote:Make everything other than white transparent first. See viewtopic.php?f=1&t=24095
A more specific reference that user snibgo is referring is to the use of sparce-color: at viewtopic.php?f=1&t=24095#p102822

This is what you are using and was written to speed up such output rather than filter on txt: output format. So it is as fast is it can get. You need to make all other pixels transparent first (-fuzz XX% +transparent white) as user snibgo suggested. That will make the process much faster to extract only the white pixels.

The original slower method was

convert image txt: | grep "white" ...