David Fanning writes:
> Is there a problem writing signed integer arrays to TIFF files?
>
> Here is my code:
>
> outFilename = Filepath('forest.tif')
> ageImage = Fix(ageImage)
> Help, ageImage
> AGEIMAGE INT = Array[8600, 8407]
> ageImage[missingIndices]=-999
> Write_Tiff, outFilename, Reverse(ageImage,2), /SHORT, /SIGNED
> testImage = Read_Tiff(outfilename)
> testimage = Reverse(testimage,2)
> Help, testImage
> TESTIMAGE BYTE = Array[8600, 8407]
>
> This is IDL 8.2.2, 64-bit, on Windows 7. '
Whoa! I left this out of my example the other day because it seemed (at
the time) completely irrelevant.
Here is test code that works perfectly:
;*********************************************
outFilename = 'forest.tif'
ageimage = read_tiff(file_which('boulder.tif'))
ageImage = Fix(ageImage)
Help, ageImage
dims = SIZE(ageimage, /DIMENSIONS)
missingIndices = long(randomu(seed, 1000) * product(dims))
ageImage[missingIndices]=-999
Write_Tiff, outFilename, Reverse(ageImage,2), GEOTIFF=geo, $
/SHORT, /SIGNED
testImage = Read_Tiff(outfilename)
testimage = Reverse(testimage,2)
Help, testImage
END
;*********************************************
Running it gives me:
AGEIMAGE INT = Array[1071, 1390]
TESTIMAGE INT = Array[1071, 1390]
BUT!!!
If I add color vectors to the file, watch this:
;*********************************************
outFilename = 'forest.tif'
ageimage = read_tiff(file_which('boulder.tif'))
ageImage = Fix(ageImage)
Help, ageImage
dims = SIZE(ageimage, /DIMENSIONS)
missingIndices = long(randomu(seed, 1000) * product(dims))
ageImage[missingIndices]=-999
TVLCT, r, g, b, /GET
Write_Tiff, outFilename, Reverse(ageImage,2), GEOTIFF=geo, $
/SHORT, /SIGNED, RED=r, GREEN=g, BLUE=b
testImage = Read_Tiff(outfilename)
testimage = Reverse(testimage,2)
Help, testImage
END
;*********************************************
AGEIMAGE INT = Array[1071, 1390]
TESTIMAGE BYTE = Array[1071, 1390]
Is that weird, or what!?
Can anyone reproduce this on their machines?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|