Page 1 of 1

can one create a txt format file with negative values

Posted: 2010-10-26T14:47:09-07:00
by fmw42
IM 6.6.5.4 Q16 HDRI

I would like to be able to create a very small 3x3 image that is a laplacian kernel as an image with the following values (so I can create its FFT):

0 -1 0
-1 4 -1
0 -1 0

I have tried to create a txt: format file and convert it to PFM or MPC or some format that supports the negative values, but identify -verbose shows bad values. Is it possible to do this?

I have create a text file tmp_lap.txt as


# ImageMagick pixel enumeration: 3,3,65535,rgb
0,0: (0,0,0)
1,0: (-1,-1,-1)
2,0: (0,0,0)
0,1: (-1,-1,-1)
1,1: (4,4,4)
2,1: (-1,-1,-1)
0,2: (0,0,0)
1,2: (-1,-1,-1)
2,2: (0,0,0)


and then tried

convert tmp_lap.txt tmp_lap.pfm

identify -verbose tmp_lap.pfm
Depth: 32/16-bit
Channel depth:
gray: 16-bit
Channel statistics:
Gray:
min: 4 (6.10361e-05)
max: 4.29497e+09 (65537)


Looks like the -1 values are being wrapped around to large positive values beyond quantumrange.


Can I change the 65535 in the txt: file header to something else that will preserve the negatives since I am in HDRI?


PS

If I do

convert tmp_lap.txt tmp_lap2.txt


then the result is


# ImageMagick pixel enumeration: 3,3,65535,rgb
0,0: ( 0, 0, 0) #000000000000 black
1,0: (65535,65535,65535) #FFFFFFFFFFFF rgb(6.5537e+06%,6.5537e+06%,6.5537e+06%)
2,0: ( 0, 0, 0) #000000000000 black
0,1: (65535,65535,65535) #FFFFFFFFFFFF rgb(6.5537e+06%,6.5537e+06%,6.5537e+06%)
1,1: ( 4, 4, 4) #000400040004 rgb(0.00610361%,0.00610361%,0.00610361%)
2,1: (65535,65535,65535) #FFFFFFFFFFFF rgb(6.5537e+06%,6.5537e+06%,6.5537e+06%)
0,2: ( 0, 0, 0) #000000000000 black
1,2: (65535,65535,65535) #FFFFFFFFFFFF rgb(6.5537e+06%,6.5537e+06%,6.5537e+06%)
2,2: ( 0, 0, 0) #000000000000 black


Which also shows that the -1 values are wrapped around to 65535