Menu

#430 JP2 reader does not read all jp2 files

OJ_2.x
closed-fixed
nobody
None
Windows
5
2021-08-08
2016-10-01
No

Orthophotographies produced by IGN are not read correctly (see maling list on 2016-10-01).
One is read with a very bad resolution, anotherone freeze the application and does not load.

Discussion

  • Jukka Rahkonen

    Jukka Rahkonen - 2016-10-06

    The issue comes from external libraries which are used for reading JPEG2000 files. That is annoying for the user but it is hard to say what to do. Open JPEG could have some methods and heuristics: You are going to open a JPEG2000 file with driver: OpenJPEG. We checked from the image metadata that its size is 12000x12000 pixels, three bands, and written as one single tile. OpenJUMP will likely freeze and you must kill the process. You are warned, do you still want to try?

     
  • ede

    ede - 2016-12-28

    it would be helpful to have test datasets attached to this ticket.

    ..ede

     
  • ede

    ede - 2016-12-29

    as a workaround use the ECW JP2 reader, only avail when OJ PLUS is run w/ java x86/32bit . seems to work fine then. unfortunately we do not have x64 binaries for these libs.

    ..ede

     
  • ede

    ede - 2020-08-28

    attach the JP2 files from above for reference

     
  • ede

    ede - 2020-09-13

    according to the below testing i would suggest we prioritize as follows when offering readers

    GDAL OpenJPEG JP2K Image Reader, version 1.1, OpenJUMP
    GDAL ECW JP2K Image Reader, version1.1, GeoSolutions/OpenJUMP
    ImageIO JPEG 2000 Image Reader, version 1.1, Sun Microsystems, Inc.

    ..ede

    some current tests w/ OJ r6458
    Java Version: OpenJDK 64-Bit Server VM 1.8.0_242 (amd64)
    OS: Windows 7 (6.1)
    Maximum memory: 1,021,837,311 bytes (974.5 MiB)
    Total Memory: 541,589,504 bytes (516.5 MiB)
    Committed Memory: 266,586,368 bytes (254.2 MiB)
    using
    https://sourceforge.net/projects/jump-pilot/files/OpenJUMP_plugins/Drivers/GDAL-win-x86x64-3.1.2stable-20200912.zip

    GDAL ECW JP2K Image Reader, version1.1, GeoSolutions/OpenJUMP

    44-2013-0303-6702-LA93-0M50-E100.jp2
    44-2013-0304-6702-LA93-0M50-E100.jp2
    loading fine side by side in ca. 4s

    974-2013-0310-7670-U40S-0M50-E080.jp2
    974-2013-0310-7670-U40S-0M50-E080.tfw
    takes a while, first draw blocks OJ for 10s or so, the envelope is bigger than the shown picture

    test.jp2
    loading fine

    ImageIO JPEG 2000 Image Reader, version 1.1, Sun Microsystems, Inc.

    44-2013-0303-6702-LA93-0M50-E100.jp2
    44-2013-0304-6702-LA93-0M50-E100.jp2
    loading ok, but wrong resolution

    974-2013-0310-7670-U40S-0M50-E080.jp2
    974-2013-0310-7670-U40S-0M50-E080.tfw
    heap space error

    test.jp2
    loading fine

    GDAL OpenJPEG JP2K Image Reader, version 1.1, OpenJUMP

    44-2013-0303-6702-LA93-0M50-E100.jp2
    44-2013-0304-6702-LA93-0M50-E100.jp2
    loading fast

    974-2013-0310-7670-U40S-0M50-E080.jp2
    974-2013-0310-7670-U40S-0M50-E080.tfw
    loading takes 22s, the envelope is bigger than the shown picture as above

    test.jp2
    loading fine

    we also have a Jasper based reader,
    GDAL Jasper JP2K Image Reader, version 1.1, GeoSolutions/OpenJUMP com.vividsolutions.jump.workbench.imagery.imageio.JP2GDALJasperImageReaderSpi
    but i don't wanna search for the needed libraries rite now.

     
  • ede

    ede - 2020-09-13

    we should probably thinking about adding a MEGA distro containing GDAL as most users are probably completely unaware of this OJ functionality

     
  • ede

    ede - 2020-09-13
    • Milestone: --> OJ_2.x
     
  • ede

    ede - 2020-09-13

    i'd say it's solved. but regardless it's not blocking OJ 1.16

     
  • michael michaud

    michael michaud - 2020-09-14

    Thanks for this fix ede. I could read successfully images with native open jpeg and ecw and I agree that we should use openjpeg first. With ImageIO JPEG 2000 Image Reader, I still get an image with a very bad resolution and compressed version takes hours to load/uncompress.
    Don't know if you tried this version :
    https://github.com/jai-imageio/jai-imageio-jpeg2000
    Maybe we can close this ticket and open a FR for a MEGA distro including GDAL. Also IMHO, the java jp2 reader still have a problem but I can open a more specific ticket for OJ_FUTURE.

     
    • ede

      ede - 2020-09-14

      On 9/14/2020 9:27, michael michaud wrote:

      Thanks for this fix ede. I could read successfully images with native open jpeg and ecw and I agree that we should use openjpeg first.

      just packaged the latest greatest GDAl and et voila ;)

      With ImageIO JPEG 2000 Image Reader, I still get an image with a very bad resolution and compressed version takes hours to load/uncompress.

      maybe we should simply not offer it? on the other hand, it's an option. as a user i like options, especially when they are not hidden from me :)

      Don't know if you tried this version :
      https://github.com/jai-imageio/jai-imageio-jpeg2000

      just tried, stack is below. the readme on https://github.com/jai-imageio/jai-imageio-jpeg2000/ also suggest to not to use it. we should probably heed their advice.

      Maybe we can close this ticket and open a FR for a MEGA distro including GDAL. Also IMHO, the java jp2 reader still have a problem but I can open a more specific ticket for OJ_FUTURE.

      sure, let's wait for Jukka's reply though.. ede

      [TRACE] 10:11:08.760 All factories fail for the operation "ImageRead" at com.vividsolutions.jump.workbench.imagery.geoimg.GeoRaster.fetchRaster(GeoRaster.java:221)
      javax.media.jai.util.ImagingException: All factories fail for the operation "ImageRead"
      at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
      at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
      at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
      at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
      at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
      at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2179)
      at com.vividsolutions.jump.workbench.imagery.geoimg.GeoRaster.fetchRaster(GeoRaster.java:211)
      SNIP
      at com.vividsolutions.jump.workbench.imagery.ReferencedImageFactoryFileLayerLoader.createImageFeature(ReferencedImageFactoryFileLayerLoader.java:213)
      at com.vividsolutions.jump.workbench.imagery.ReferencedImageFactoryFileLayerLoader.open(ReferencedImageFactoryFileLayerLoader.java:106)
      at org.openjump.core.ui.plugin.file.open.OpenFileWizard.run(OpenFileWizard.java:164)
      at org.openjump.core.ui.plugin.file.OpenWizardPlugIn.run(OpenWizardPlugIn.java:110)
      at com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:151)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
      at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
      ... 19 more
      Caused by: java.lang.RuntimeException: java.lang.RuntimeException: jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/github/jaiimageio/jpeg2000/impl/J2KMetadata;)V
      at com.sun.media.jai.imageioimpl.ImageReadCRIF.create(ImageReadCRIF.java:317)
      ... 25 more
      Caused by: java.lang.RuntimeException: jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/github/jaiimageio/jpeg2000/impl/J2KMetadata;)V
      at com.github.jaiimageio.jpeg2000.impl.J2KReadState.initializeRead(J2KReadState.java:682)
      at com.github.jaiimageio.jpeg2000.impl.J2KReadState.<init>(J2KReadState.java:195)
      at com.github.jaiimageio.jpeg2000.impl.J2KImageReader.readHeader(J2KImageReader.java:370)
      at com.github.jaiimageio.jpeg2000.impl.J2KImageReader.getImageTypes(J2KImageReader.java:384)
      at javax.imageio.ImageReader.getRawImageType(ImageReader.java:681)
      at com.sun.media.jai.imageioimpl.ImageReadOpImage.layoutHelper(ImageReadOpImage.java:228)
      at com.sun.media.jai.imageioimpl.ImageReadOpImage.<init>(ImageReadOpImage.java:473)
      at com.sun.media.jai.imageioimpl.ImageReadCRIF.create(ImageReadCRIF.java:309)
      ... 25 more
      Caused by: java.lang.NoSuchMethodError: jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/github/jaiimageio/jpeg2000/impl/J2KMetadata;)V
      at com.github.jaiimageio.jpeg2000.impl.J2KReadState.initializeRead(J2KReadState.java:403)
      ... 32 more</init></init></init></init></init>

       
  • Jukka Rahkonen

    Jukka Rahkonen - 2020-09-14

    IMHO Jasper and jj2000 are rather useless for geospatial images. OpenJPEG is quite nice nowadays, open source, and getting better so +1 for having it as the first option.

     
    • ede

      ede - 2020-09-14

      On 9/14/2020 11:36, Jukka Rahkonen wrote:

      IMHO Jasper and jj2000 are rather useless for geospatial images. OpenJPEG is quite nice nowadays, open source, and getting better so +1 for having it as the first option.

      will reorder accordingly.

      Jukka, did you ever try

      JP2KAK (avail in OJ via imageio-ext)
      JPEG-2000 (based on Kakadu)

      JP2LURA
      JPEG2000 driver based on Lurawave library

      JP2MrSID (avail in OJ via imageio-ext)
      JPEG2000 via MrSID SDK

      via GDAL? we could add JP2LURA to OJ if it makes sense?..ede

       
  • Jukka Rahkonen

    Jukka Rahkonen - 2020-09-14

    I have used Kakadu with GDAL years ago but because OpenJPEG driver is quite good I have not bothered lately even I do have Kakadu license. Kakadu, Lura, and MrSID all have expensive licenses and they not at all common among GDAL users. If we add JP2LURA I do not know who could help them with their problems. I do not even know where Lura JPEG2000 is nowadays, the company is perhaps sold here https://www.foxitsoftware.com/enterprise-automation/products/. But if the old libraries work and they are not too heavy I am not strongly against including them.

     
  • ede

    ede - 2021-08-08
    • status: open --> closed-fixed
     
  • ede

    ede - 2021-08-08

    close it as GDAL-OpenJPEG seems good enough for now.

     

Log in to post a comment.

MongoDB Logo MongoDB