Le mercredi 15 avril 2015 21:46:26, Dr. Joshua Jackson a écrit : > 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?
The "metadata" you're talking about are more the georeferencing info, right ? (In GDAL "metadata" is about all other metadata, excluding the georeferencing) If you use trunk, you could likely try the new USE_SRC_CODESTREAM=YES creation open of the jp2openjpeg driver Something like: gdal_translate your_jp2_without_georef.jp2 out.jp2 -co USE_SRC_CODESTREAM=YES -a_srs EPSG:4326 -a_ullr -96.9653320 32.4645996 -96.9598389 32.4591064 The SetGeoTransform() and SetProjection() API also do something similar internally, so you could also do : gdal_edit.py your_jp2_without_georef.jp2 -a_srs EPSG:4326 -a_ullr -96.9653320 32.4645996 -96.9598389 32.4591064 or more conveniently: gdalcopyproj.py middle_mask.jp2 out.jp2 (http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/gdalcopyproj.py) Even > > 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> [email protected] <mailto:[email protected]> 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> -- Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
