Hi,
My guess is that the call to WRITE_TIFF is bad. I bring this up because by default I think the written data type for WRITE_TIFF is byte data which means that your speckles probably come from your data being a 16 bit or 32 bit integer. To illustrate how to correctly write a TIFF image, I included a sample program below. The first procedure is used to generate a. HDF5 data file, the second procedure is used to convert it to a TIFF. This code will only work if you have ENVI installed because it uses ENVI to extract raster data from a sample image that is included with the installation. To run the program just save all of the code below as hdf5_to_tiff.pro then compile and run. Once completed, an HDF5 file and TIFF file will be generated in the same directory that the code is saved to.
;==========================================================================
;beginning of code
;==========================================================================
pro make_hdf5_file
compile_opt idl2
;get current directorya nd specify output file
thisdir = FILE_DIRNAME(((SCOPE_TRACEBACK(/STRUCT))[-1]).FILENAME)
outfile = thisdir + path_sep() + 'h5_out.h5'
;delete output file if it exists
if file_test(outfile) then FILE_DELETE, outfile, /QUIET
e = envi(/headless)
;open sample data to write to HDF5 file
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.openraster(file)
raster_data = raster.getdata()
raster_dims = size(raster_data, /DIMENSIONS) ;[n, m, 4] for dimensions
; create HDF5 file
fid = H5F_CREATE(outfile)
;create bands of data in the HDF5 file
datatype_id = H5T_IDL_CREATE(raster_data)
dataspace_id = H5S_CREATE_SIMPLE(raster_dims)
dataset_id = H5D_CREATE(fid,'qb_boulder_msi',datatype_id,dataspace_id)
; write the raster_data to the dataset
H5D_WRITE,dataset_id,raster_data
; close the identifiers
H5S_CLOSE,dataspace_id
H5T_CLOSE,datatype_id
H5F_CLOSE,fid
;close ENVI
e.close
end
pro hdf5_to_tiff
compile_opt idl2
;get current directorya nd specify output file
thisdir = FILE_DIRNAME(((SCOPE_TRACEBACK(/STRUCT))[-1]).FILENAME)
infile = thisdir + path_sep() + 'h5_out.h5'
outfile = thisdir + path_sep() + 'h5_out.tif'
;read image data
img_data = H5_GETDATA(infile, '/qb_boulder_msi')
;because our data is unsigned integers (16 bit) we need /SHORT keyword set
write_tiff, outfile, img_data, PLANARCONFIG = 2, /SHORT
end
;main level program
compile_opt idl2
make_hdf5_file
hdf5_to_tiff
end
;==========================================================================
;end of code
;==========================================================================
|