[gdal-dev] Copy meta data from one JP2 to another JP2 C++

Dr. Joshua Jackson josh at nside.io
Wed Apr 15 12:46:26 PDT 2015


I’m looking for a good solution to copy the image meta data from one JP2 to another JP2 in C++.  I have a folder full of 4096x4096 JPEG2000 images that I am processing with OpenCV.  On some of them I create a copy of the image and do some manipulations to.  As expected the new image file is missing all the metadata.

I have tried using CreateCopy() with the OpenJPEG library; and while this does work it takes a really long time per image ~40sec.  (My image manipulations take only ~10sec).

Is there some way to use the GetGDALDataSet() on the source file and then call SetMetaData() on the destination file for each meta data item?  How would one iterate through the metadata items?

Here is a sample GDALInfo printout for a source image:

Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library
Files: middle_mask.jp2
Size is 4096, 4096
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-96.965332031250000,32.464599609375000)
Pixel Size = (0.000001341104507,-0.000001341104507)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  ( -96.9653320,  32.4645996) ( 96d57'55.20"W, 32d27'52.56"N)
Lower Left  ( -96.9653320,  32.4591064) ( 96d57'55.20"W, 32d27'32.78"N)
Upper Right ( -96.9598389,  32.4645996) ( 96d57'35.42"W, 32d27'52.56"N)
Lower Right ( -96.9598389,  32.4591064) ( 96d57'35.42"W, 32d27'32.78"N)
Center      ( -96.9625854,  32.4618530) ( 96d57'45.31"W, 32d27'42.67"N)
Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red
  Overviews: 2048x2048, 1024x1024, 512x512, 256x256
  Overviews: arbitrary
Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green
  Overviews: 2048x2048, 1024x1024, 512x512, 256x256
  Overviews: arbitrary
Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue
  Overviews: 2048x2048, 1024x1024, 512x512, 256x256
  Overviews: arbitrary


Joshua Jackson, PhD
Senior ResearchEngineer
 (800) 604-1822 Ext. 5109 <tel:8006041822,5109>   (256) 648-5109 <tel:2566485109>
 josh at nside.io <mailto:josh at nside.io>   www.nSide.io
 <http://www.nside.io/> 4031 Parkway Dr, Suite B, Florence, AL 35630
  <http://www.linkedin.com/company/nside/>  <http://twitter.com/nSide__Out>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150415/ef9ada61/attachment-0001.html>


More information about the gdal-dev mailing list