<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Even,<br>
      <br>
      Le 19/05/2014 20:01, Even Rouault a écrit :<br>
    </div>
    <blockquote
      cite="mid:201405192001.48688.even.rouault@mines-paris.org"
      type="cite">
      <pre wrap="">Guillaume,

</pre>
      <blockquote type="cite">
        <pre wrap="">
I am using the OpenJPEG driver from GDAL and I noticed some differences
with the behaviour of an other OpenJPEG "driver" that I used before in
the library Orfeo ToolBox. The GDAL driver fails to pass a conformance
test : using the input file "jpeg2000_conf_p1_06.j2k" 
</pre>
      </blockquote>
      <pre wrap="">
Are you refering to 
<a class="moz-txt-link-freetext" href="http://code.google.com/p/openjpeg/source/browse/data/input/conformance/p1_06.j2k">http://code.google.com/p/openjpeg/source/browse/data/input/conformance/p1_06.j2k</a> 
? I see this is a 12 x 12 pixel image ...</pre>
    </blockquote>
    Yes, this is a 12x12 image.<br>
    <blockquote
      cite="mid:201405192001.48688.even.rouault@mines-paris.org"
      type="cite">
      <pre wrap="">

</pre>
      <blockquote type="cite">
        <pre wrap="">, reading the
resolution level 4 (zero being the original image) , it should produce a
1x1 image with the pixel value [195, 36, 100].

The behaviour of GDAL drivers differs on the following points :

  * The number of overviews detected for a jpeg2000 dataset is limited
    (no overview if its dimensions are both lower than 256). Even if the
    the overviews can be computed by GDAL, it won't use the wavelet
    coefficients for the highest levels, but rather perform the default
    nearest neighbor interpolation.
</pre>
      </blockquote>
      <pre wrap="">
Yes, this is to avoid exposing overviews that are too small and do not make 
pratical sense. Other JPEG2000 drivers, such as JP2KAK or JP2ECW, have similar 
logic.

</pre>
      <blockquote type="cite">
        <pre wrap="">  * The size of the overview at level 'n' is computed as : ovr_size =
    raster_size / 2^n , whereas it should be ovr_size = ceil(
    raster_size / float(2^n) )

</pre>
      </blockquote>
      <pre wrap="">
Hum, any reason to particularly round to the upper value rather than the lower 
value ? The JP2ECW driver does the rounding to the lower value too.</pre>
    </blockquote>
    This rounding to the upper value is done in OpenJpeg (for instance :
    <tt>src/lib/openjp2/j2k.c:7648</tt> ). I think it is also used to
    compute the maximum number of resolutions. I am not sure if using a
    lower-value rounding in GDAL driver has an impact on the
    decompressed images (other than a possible crop).<br>
    <blockquote
      cite="mid:201405192001.48688.even.rouault@mines-paris.org"
      type="cite">
      <pre wrap="">

</pre>
      <blockquote type="cite">
        <pre wrap="">
I am using GDAL 1.10.1 and OpenJpeg 2.0.
Is it relevant to report a bug on this topic ?
</pre>
      </blockquote>
      <pre wrap="">
IMHO the test case seems to be a bit too artificial to justify any change, 
unless there are real world cases where that would cause issues.</pre>
    </blockquote>
    I agree that this is a corner case, and I guess you would like to
    keep a consistent behaviour between the different jpeg2000 drivers.
    My worry is more about the compliance with the standard. <br>
    <blockquote
      cite="mid:201405192001.48688.even.rouault@mines-paris.org"
      type="cite">
      <pre wrap="">

Even

</pre>
    </blockquote>
    <br>
    <br>
    <div class="moz-signature">-- <br>
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td><a href="www.c-s.fr" hreflang="fr"><img
                  src="cid:part1.02090906.01020600@c-s.fr" alt=""
                  align="left" border="0"></a> </td>
            <td><font size="1" face="verdana">
                <b>Guillaume PASERO</b><br>
                Ingénieur d'études et développement<br>
                <a
                  href="https://thor.si.c-s.fr/blogs/cs-blogs-business/">
                  <b>Business Unit E-SPACE & Geo Information</b></a><b>
                  - Département APPLICATIONS</b><br>
                <br>
                <b>CS Systèmes d'Information</b><br>
                Parc de la Grande Plaine - 5, Rue Brindejonc des
                Moulinais - BP 15872<br>
                31506 Toulouse Cedex 05 - FRANCE<br>
                +33 561 17 64 21 - <a class="moz-txt-link-freetext"
                  href="mailto:guillaume.pasero@c-s.fr">guillaume.pasero@c-s.fr</a>
              </font></td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>