can one create a txt format file with negative values

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

can one create a txt format file with negative values

Post 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
Post Reply