JPEG2000 is an image compression standard that defines a file format, includes significant new features and capabilities, and provides for both reversible (lossless) image compression, and irreversible (lossy) image compression.
Table of Contents
- Kakadu kdu_compress progress report
- Kakadu for Mac OS X
- Kakadu version 6.3.1 Burken patch
- Kakadu version 6.3.1 released
- Kakadu version 6.3 released
- Compiling GDAL version 1.6.2 with gcc
- Compiling Kakadu version 6.2.1 with gcc
- Kakadu version 6.2.1 handling of TIFF images
- Kakadu version 6.2.1 released
- Kakadu version 6.2 released
- QGIS properly displays JPEG2000 images
- Kakadu Mac Intel 64 bit 20% faster than 32 bit
- Creating an RGB JP2 image from three single channel TIFF images
- Creating a reversible JPEG2000 image
- JPG versus JPEG2000
- Quickly converting the georeferencing info stored in a GeoJP2 file to text
- Web site with GDAL and QGIS compiled for Mac OS X
- Tech News Web Sites, with a presenter
- Contact Greg Coats
Kakadu kdu_compress progress report
At the conclusion of JPEG2000 processing, Kakadu kdu_compress outputs a one line summary message, similar to this
Generated 20 tile-part(s) for a total of 20 tile(s).
While this is useful, I am interesting in having kdu_compress also provide a progress report during JPEG2000 processing, followed by the typical one line summary message at the conclusion of JPEG2000 processing. Roland Sweet and I have added 20 lines of code to kdu_compress.cpp, version 6.3.1, so that it proactively reports progress, similar to this
JP2 tiles to process = 20
JP2 tiles processed = 2 4 6 8 10 12 14 16 18 20
Generated 20 tile-part(s) for a total of 20 tile(s).
Our code has been provided to Professor Taubman, so that it can be considered for incorporation into the next release of Kakadu. If you are interested in the progress report code, contact me.
Kakadu for Mac OS X
To read and write .jp2 files, the Apple Mac OS X version 10.6.2 image viewing application Preview version 5.0.1 depends upon Kakadu version 5.2.1, that was released on Tue 15 Aug 2006. Since then, these Kakadu updates have been released: versions 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 6.0, 6.1, 6.1.1, 6.2, 6.2.1, 6.3, 6.3.1.
Kakadu version 6.3.1 executables, compiled for Mac OS X, can be downloaded for free from
Kakadu for Mac OS X.
Kakadu version 6.3.1 Burken patch
Dave Burken advises that for Kakadu version 6.3.1 to properly support signed 16 bit data, line 4277 of apps/support/kdu_region_decompressor.cpp should be changed from
precision_bits,false);
to
precision_bits,chan->native_signed);
Kakadu version 6.3.1 released
On Tuesday 17 November 2009, Professor Taubman released the JPEG2000 Kakadu software version 6.3.1. The file Updates.txt notes that version 6.3.1 includes 7 minor improvements.
Kakadu version 6.3 released
Needs two changes
On Tuesday 3 November 2009, Professor Taubman released the JPEG2000 Kakadu software version 6.3. The following two changes should be made in apps/image/image_out.cpp before compiling. The lines changed are in bold.
Beginning at line 918
if ((upshift == 0) && (downshift == 0))
{ // Common case
for (; num > 0; num--, src++, dest+=inter_sample_bytes)
{
int x = src->ival;
x = (x >= x_min)?x:x_min;
x = (x <= x_max)?x:x_max;
x = x + offset;
dest[0] = (kdu_byte) x;
}
}
Beginning at line 1989
iptc_box.read(iptc_data_packet,length_of_iptc_tag);
// Writing IPTC metadata as Type=Long=4
tiffdir.write_tag(/*(((kdu_uint32) 33723)<<16) + 0x0004*/
(kdu_uint32) 0x83bb0004,length_of_iptc_tag,
iptc_data_packet);
Without the change beginning at line 918, a .tif file created by kdu_expand for an 8 bit image will have about 90% of its pixels improperly created as black.
Without the change beginning at line 1989, LibTiff will report the following error for .tif files created by kdu_expand with TIFF tag 33723 IPTC metadata:
TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored.
Compiling GDAL version 1.6.2 with gcc
Compiling GDAL version 1.6.2's JP2KAK Kakadu-based JPEG2000 support in frmts/jp2kak/jp2kakdataset.cpp with gcc version 4.2.1, yields from the section
Set some user-overridable parameters.
the following warning 15 times
jp2kakdataset.cpp:2472: warning: deprecated conversion from string constant to ‘char*’
A small syntax change to line 2460 eliminates these warnings. To download an updated jp2kakdataset.cpp that does not yield any compiler warnings, select the following link jp2kakdataset.cpp
Compiling Kakadu version 6.2.1 with gcc
Compiling Kakadu version 6.2.1 with gcc version 4.2.1 yields the following warning 45 times
warning: deprecated conversion from string constant to ‘char*’
To eliminate this warning for apps/kdu_compress/kdu_compress.cpp, change the fifth line after main = line 2758 from
kdu_args args(argc,argv,"-s");
to
kdu_args args(argc,argv,(char *)"-s");
To eliminate this warning for kdu_expand.cpp, similarly modify line 1667.
You will likely want to similarly modify the other Kakadu kdu_*.cpp programs that you compile.
Kakadu version 6.2.1 handling of TIFF images
There is a one character typo in Kakadu version 6.2.1 in apps/image/image_out.cpp, at line 1669.
apps/image/image_out.cpp line 1669 is
kdu_long out_byte_count = ((kdu_long)rows) & ((kdu_long)scanline_width);
apps/image/image_out.cpp line 1669 should be
kdu_long out_byte_count = ((kdu_long)rows) * ((kdu_long)scanline_width);
The only change is replacing & with *.
Unfortunately, the result of this typo is that all .tif files written by kdu_expand have an invalid StripByteCounts value. Trying to read these .tif files yields the error message TIFFReadDirectory:Bogus "StripByteCounts" field. As a consequence, some TIFF viewers are unable to display the image contained in .tif files created by version 6.2.1 of kdu_expand.
Additionally, I discovered some software bugs in Kakadu version 6.2.1, related to the new way that .tif files are read and written when they
1. include TIFF tag 700 XMP metadata
2. include TIFF tag 33723 IPTC metadata
3. are larger than 2 GB
4. are larger than 4 GB, BigTiff images
The solution requires changes to
apps/image/image_in.cpp
apps/image/image_out.cpp
apps/image/kdu_tiff.cpp
I emailed to Professor Taubman corrected image_out.cpp and kdu_tiff.cpp files, and he has indicated that he plans to fix image_in.cpp, so that it will respect endianness when reading and storing TIFF tag 33723 IPTC metadata, and will then incorporate all of these changes in Kakadu version 6.2.2, that he said on Monday 7 September 2009 will be released "soon".
Kakadu version 6.2.1 released
On Sunday 2 August 2009, Professor Taubman released the JPEG2000 Kakadu software version 6.2.1. The file Updates.txt notes that version 6.2.1 includes 5 minor improvements.
Kakadu version 6.2 released
On Friday 3 July 2009, Professor Taubman released the JPEG2000 Kakadu software version 6.2. The file Updates.txt notes that version 6.2 includes 34 improvements, including these 5 enhancements, that I suggested:
- Added support for the BigTIFF file format to the "kdu_compress" and "kdu_expand" demo applications by modifying Kakadu's `kdu_tiff' class to support both regular TIFF and the new BigTIFF format -- modifications to "image_in.cpp" and "image_out.cpp" to support BigTIFF were almost negligible, but modifications to the `kdu_tiff' class that they use for TIFF support were more substantial. In any event, you can now read and write TIFF files much larger than 4GB in size. Suggested by Greg Coats. [The code in apps/image/image_out.cpp on line 1670 causes kdu_expand to use BigTIFF when writing .tif files that will have more than 3,600,000,000 bytes of pixels.]
- Slightly modified "kdu_compress" and "kdu_expand" so that they read/write XMP and IPTC metadata found in TIFF files and JP2 files, as suggested by Greg Coats.
- Added the resolution scaling adjustments suggested by Greg Coats to GeoJP2 information written back to TIFF files by "kdu_expand", so that any resolution reduction is taken into account. Simultaneously modified the way in which display resolution attributes are adjusted, so that resolution information recorded in the output file (BMP or TIFF) remains correct under both resolution reduction and cropping to a region of interest.
- Fixed a bug in the TIFF reading code used by the "kdu_compress" demo application, which causes LZW compressed tiled images to be read incorrectly. Problem reported by Greg Coats, with fix provided by Margaret Lepley.
- Removed the second writing of TIFF tag RowsPerStrip when generating GeoJP2 boxes in "image_in.cpp", which was a typo. This fix was provided by Greg Coats.
QGIS properly displays JPEG2000 images
I am pleased to report that as a result of changes made on Monday 5 January 2009 to GDAL files 1.6/gdal/frmts/jpeg2000/jpeg2000dataset.cpp and 1.6/gdal/frmts/jp2kak/jp2kakdataset.cpp, QGIS properly displays JPEG2000 images using Jasper and Kakadu.
Kakadu Mac Intel 64 bit 20% faster than 32 bit
The Kakadu version 6.0 JPEG2000 software can be compiled under Apple Mac OS X 10.4 for both the Mac Intel 32 bit environment, and the Mac Intel 64 bit environment. Under Mac OS X 10.4, the Kakadu version 6.0 Mac Intel 64 bit executables are about 20% faster than the Mac Intel 32 bit executables, on an Intel Core 2 Duo, 2.33 GHz Mac.
| Kakadu version 6.0 |
32 bit |
64 bit |
speed up |
| kdu_compress |
5.65 sec |
4.69 sec |
20% |
| kdu_expand |
2.62 sec |
2.12 sec |
23% |
Creating an RGB JP2 image from three single channel TIFF images
The Kakadu syntax for combining three single channel TIFF files, representing the red, green, and blue channels, into an RGB JPEG2000 file is
kdu_compress -i red.tif,green.tif,blue.tif -o rgb.jp2 -jp2_space sRGB
Creating a reversible JPEG2000 image
The syntax for creating from a reversible (lossless) .jp2 file from a .tif input file, with Kakadu and GeoJasPer is
kdu_compress -i input_image.tif -o output_image.jp2 Creversible=yes
geojasper -f input_image.tif -F output_image.jp2
JPG versus JPEG2000
A single image from my JPG versus JPEG2000 movie, comparing JPG versus JPEG2000 versus uncompressed at the compression ratio of 108:1, showing the 3 images, and their 3 histograms, and is available for free downloading as a 1.3 MB PNG image, 1540 colums by 844 rows.
Quickly converting the georeferencing info stored in a GeoJP2 file to text
An example of the GeoJasPer syntax to quickly display as text a GeoJP2 file's georeferencing info, without decompressing the .jp2 file, is
geojasper -f 18stj940125.jp2 -T tif -o listgeo
Below is an example of the listgeo output from GeoJasPer version 1.2.9.
Note that while this GeoJP2 file stores its georeferencing info only in UTM coordinates, geojasper reports the corner and center coordinates in both UTM and latitude/longitude coordinates.
Geotiff_Information:
Version: 1
Key_Revision: 1.0
Tagged_Information:
ModelTiepointTag (2,3):
0 0 0
294000 4314000 0
ModelPixelScaleTag (1,3):
0.3 0.3 0
End_Of_Tags.
Keyed_Information:
GTModelTypeGeoKey (Short,1): ModelTypeProjected
GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
GeogGeodeticDatumGeoKey (Short,1): Datum_North_American_Datum_1983
GeogEllipsoidGeoKey (Short,1): Ellipse_GRS_1980
ProjectedCSTypeGeoKey (Short,1): PCS_NAD83_UTM_zone_18N
PCSCitationGeoKey (Ascii,58): "Universal Transverse Mercator; North American 1983; GRS80"
ProjLinearUnitsGeoKey (Short,1): Linear_Meter
ProjNatOriginLongGeoKey (Double,1): -75
ProjNatOriginLatGeoKey (Double,1): 0
ProjFalseEastingGeoKey (Double,1): 500000
ProjFalseNorthingGeoKey (Double,1): 0
ProjScaleAtNatOriginGeoKey (Double,1): 0.9996
End_Of_Keys.
End_Of_Geotiff.
PCS = 26918 (NAD83 / UTM zone 18N)
Projection = 16018 (UTM zone 18N)
Projection Method: CT_TransverseMercator
ProjNatOriginLatGeoKey: 0.000000 ( 0d 0' 0.00"N)
ProjNatOriginLongGeoKey: -75.000000 ( 75d 0' 0.00"W)
ProjScaleAtNatOriginGeoKey: 0.999600
ProjFalseEastingGeoKey: 500000.000000 m
ProjFalseNorthingGeoKey: 0.000000 m
GCS: 4269/NAD83
Datum: 6269/North American Datum 1983
Ellipsoid: 7019/GRS 1980 (6378137.00,6356752.31)
Prime Meridian: 8901/Greenwich (0.000000/ 0d 0' 0.00"E)
Projection Linear Units: 9001/metre (1.000000m)
Corner Coordinates:
Upper Left ( 294000.000, 4314000.000) ( 77d22'37.88"W, 38d57' 2.74"N)
Lower Left ( 294000.000, 4312500.000) ( 77d22'36.25"W, 38d56'14.12"N)
Upper Right ( 295500.000, 4314000.000) ( 77d21'35.61"W, 38d57' 4.01"N)
Lower Right ( 295500.000, 4312500.000) ( 77d21'34.00"W, 38d56'15.39"N)
Center ( 294750.000, 4313250.000) ( 77d22' 5.94"W, 38d56'39.07"N)
Web site with GDAL and QGIS compiled for Mac OS X
Kyngchaos is a web site, frequently updated, that offers for free GDAL and QGIS compiled for Mac OS X.
The Geospatial Data Abstraction Library web site is available at GDAL.
The Quantum GIS web site is available at QGIS.
Tech News Web Sites, with a presenter
GeekBrief.TV "Shiny, happy tech news." Based in Dallas, Texas, USA. Presented by Luria Petrucci portraying Cali Lewis.
Rocketboom says "We cover and create a wide range of information and commentary from top news stories to quirky internet culture." Based in New York City, New York, USA. Presented by Molly Windman.
Contact Greg Coats
Click to contact Greg Coats, the creater of this web site, via email.