[Gdal-dev] Improving img support

Andreas Wimmer andreas.wimmer at joanneum.at
Fri Jul 16 09:20:55 EDT 2004


Hi!
I am currently working on using gdal specifically the img driver to access
erdas img-images from our image processing framework.
While working on it I found a number of issues with the gdal support for 
img images. I solved these issues with the patches I append to this posting.

1) clean_force_external_spill.patch
In the latest version of gdal (1.2.1) support for a use-option SPILL_FILE
was added. Unfortunately a similar option named USE_SPILL already existed
for some time. This patch cleans up this inconsitency by using the USE_SPILL
option. (which is the better name IMO ).
Additionally this patch changes the behaviour of the img-driver to now
always creating the HFA Entry "IMGFormatInfo" (of type ImgFormatInfo831)
When using an external spill file the element "spaceUsedForRasterData" is
set to zero, otherwiese to the number of bytes used for the blocks stored
in the file (ie. nBytesPerBlock*nBlocks*nBands ) This is done for
compliance with Erdas imagine which also sets this Elemten the same way.

2) block_size_support.patch
This patch addes a new user option named "BLOCKSIZE" which allows the 
specification of the Blocksize used to write the images. Until now the 
blocksize was fixed to 64 Pixels, which was rather small for our purposes
and gave poor results when doing image io over network connections.
The patch includes a sanity check which only allows sizes between 32 and 
2048 Pixels, if values outside this range are specified the default value of
64 Pixels is used.
Addtionally this patch cures a problem with 32 bit unsigned integer files.
The img file format documentation states thet the dictionaryPtr element of
the Ehfa_Layer entry shall point to an Dictionary of the form
"{<n>:<t>,}RasterDMS,." where the t shall be the char ´i´ for uint32. For
some reason the leads to errors ("out of memory") for erdas imagine. Erdas
imagine itself uses an "L" in this case so I changed the gdal-code
accordingly.


3) metadata_infrastructure.patch
In an attempt to improve the handling of statistics and histogram I used
the Set/GetMetadataInterface. The img-driver uses a fixed set of
metadata-items which are read from hfa-entries used by imagine and the
meta-data entry specific to gdal, but these value are always written to the
gdal specific meta-data entry. Hence erdas imagine cannot make use of
statistics created with gdal based img files.
This patch moves and extends the fixed set of meta-data items form
hfadataset.cpp to hfaopen.cpp. Additionally it adds a declaration for a
function "GetHFAAuxMetaDataList" to hfa_p.h. This function is implemented
in hfaopen.h and returns the list of metadata item definitions.
This list is also extended by some histgram related items. This definition
now contains four elements instead of 3 for the item definitions to
additionally specify the hfa-entry element where the items should be read
from.

4) set_metadata.patch
requires metadata_infrastructure.patch.
This patch changes the behaviour of HFASetMetadata. Instead of writing the
metadata infor the a gdal specific hfa entry, the new code writes the data
to the entries which are used by erdas imagine, namely the entry
"Statistics" of type Esta_Statistics or "HistogramParameters" of type
Eimg_StatisticsParameters830 (specified by the meta-data definition).

5) histogram.patch
requires set_metadata.patch
This patch adds the ability to read and store Histogram data in img files in 
and erdas imagine compatible way. The histogram data is passed over the
Metadata interface in the "STATISTICS_HISTOBINVALUES" item.
This item is supposed to be a list of integer values separated by a '|'
(vertical bar). Additional parameters are STATISTICS_HISTONUMBINS (the
number of bins),  STATISTICS_HISTOMIN (the min value coverd by the
histogram) and STATISTICS_HISTOMAX (the max value).
The patch always creates "linear histgrams" with integer counter fields.
The skip-factor fields are set to 1. The read functionality for histograms 
support integer and double counters.

I hope these patches are usefull and can be included in the gdal
distribution

Best Regards,
Andreas


-- 
Andreas Wimmer
andreas.wimmer at joanneum.at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: block_size_support.patch
Type: text/x-diff
Size: 1500 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040716/acb465ef/block_size_support.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clean_force_external_spill.patch
Type: text/x-diff
Size: 1418 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040716/acb465ef/clean_force_external_spill.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: histogram.patch
Type: text/x-diff
Size: 5176 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040716/acb465ef/histogram.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: metadata_infrastructure.patch
Type: text/x-diff
Size: 4736 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040716/acb465ef/metadata_infrastructure.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: set_metadata.patch
Type: text/x-diff
Size: 5094 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040716/acb465ef/set_metadata.bin


More information about the Gdal-dev mailing list