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.
I need a faster way to generate locations of white pixels
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: I need a faster way to generate locations of white pixel
Make everything other than white transparent first. See viewtopic.php?f=1&t=24095
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: I need a faster way to generate locations of white pixel
A more specific reference that user snibgo is referring is to the use of sparce-color: at viewtopic.php?f=1&t=24095#p102822snibgo wrote:Make everything other than white transparent first. See viewtopic.php?f=1&t=24095
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" ...