Hi all IM users,
How to explain my problem ?
Well, I've got a png file which contains radar precipitation. The png size in pixel is 1536x1536 pixels.
So I would like to extract :
X Y Value like
1 0 pixelValue
2 0 pixelValue
.
.
.
etc...
In another file I have information of each od these 1536 pixels x 1536 pixels concerning coordinates
I got for this a .prj
ncols 1536
nrows 1536
xllcorner -619652.074056195910
yllcorner -5062818.337687556632
cellsize 999.999999840583
NODATA_value 63
As you can see
- We find the ncols and nrows
- We know the coordinates of the (0,0) pixels
- we know the pixels size which tell me the coordinate of each pixel.
The problem is that I'd like to extract each pixel of the png file and its Value
Do you think that there is a command to do this ?
Thank you very much for your helps.
Best regard
Stefan
Extract value from a png file with coordinate
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract value from a png file with coordinate
If you want to dump the entire image to a large text file:
If you want the RGB components of just one pixel:
... where XX and YY are the required integer coordinates.
Many other methods are available, including non-integer coordinates, if you need them.
Code: Select all
convert in.png txt:
Code: Select all
convert in.png -precision 9 -format "ONE_PIXEL.R=%[fx:p{XX,YY}.r]\nONE_PIXEL.G=%[fx:p{XX,YY}.g]\nONE_PIXEL.B=%[fx:p{XX,YY}.b]"info:
Many other methods are available, including non-integer coordinates, if you need them.
snibgo's IM pages: im.snibgo.com
Re: Extract value from a png file with coordinate
Hi Snibgo
I don't know how th thank you. It's so simple
convert in.png txt :
The second way wil be very usefull to extract value on one pixel because as I said I can know the geographic equivalent coordinate.
Thank thank thank for you help.
May I ask If I would able to find this command in the IM command pages ?
Stefan
I don't know how th thank you. It's so simple
convert in.png txt :

The second way wil be very usefull to extract value on one pixel because as I said I can know the geographic equivalent coordinate.
Thank thank thank for you help.
May I ask If I would able to find this command in the IM command pages ?
Stefan
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract value from a png file with coordinate
For "txt:", see http://www.imagemagick.org/Usage/files/#txt
For p{...}, see http://www.imagemagick.org/script/fx.php
For p{...}, see http://www.imagemagick.org/script/fx.php
snibgo's IM pages: im.snibgo.com
Re: Extract value from a png file with coordinate
Thank you very much Snibgo
Stéfan
Stéfan