<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:Calibri;
color:windowtext;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Hi Even,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"> Here is my first cut at fixing the half pixel shifts:
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><a href="https://github.com/piyushrpt/gdal/commit/ead79550e7120767187a0b9c836b5d861223d997">https://github.com/piyushrpt/gdal/commit/ead79550e7120767187a0b9c836b5d861223d997</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">With these changes, the shifts are down to sub 0.2 pixels. Still not sure if I got the math right. Feel like the errors should be smaller for the ideal simulated datasets that I’m using.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Piyush<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">Even Rouault <even.rouault@spatialys.com><br>
<b>Date: </b>Thursday, September 28, 2017 at 3:36 PM<br>
<b>To: </b>"Agram, Piyush S (334D)" <Piyush.Agram@jpl.nasa.gov><br>
<b>Cc: </b>"gdal-dev@lists.osgeo.org" <gdal-dev@lists.osgeo.org><br>
<b>Subject: </b>Re: [gdal-dev] Geolocation arrays - location interpretation<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">On jeudi 28 septembre 2017 22:18:31 CEST Agram, Piyush S (334D) wrote:<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> Hi Even,<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> I implemented the bilinear weighting like we discussed and that took out<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> the systematic pixel shift from 1 to 0.5 (sign depending on orientation).<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> You can see the changes here:<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> https://github.com/piyushrpt/gdal/commit/b199cbae9ea15e31c787c1480c342bb84de<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> bf774<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> I also tried playing with the upsampling factor (1.3 to 4.0) and the<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> discrepancy numbers were consistent after 1.5. Probably, the minimum needs<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> to be sqrt(2) for square pixels.<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Using the weighting fixed the truncation<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> / rounding error and the results seem consistent when I move the output<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> extent around.
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> The systematic 0.5 pixel shift suggests that there is still an issue. Is my<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> interpretation that the GeoLocTransformer is supposed to operate on pixel<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> center coordinates correct?<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">i.e – if my geoloc arrays were regular grid<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> and I feed in the coordinates to the transformer, they return pixel centers<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> – 0.5,0.5 etc. I’m going to try implementing some round trip checks to see<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">> if that shows something?
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Yes I agree there must be a 0.5 pixel shift issue when looking at the forward path in GDALGeoLocTransform(), ie the one taken by if( !bDstToSrc )<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">So we have currently<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">const double dfGeoLocPixel =<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">(padfX[i] - psTransform->dfPIXEL_OFFSET)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">/ psTransform->dfPIXEL_STEP;<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">const double dfGeoLocLine =<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">(padfY[i] - psTransform->dfLINE_OFFSET)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">/ psTransform->dfLINE_STEP;<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">For example take the case of offset = 0 and step = 1 to simplify<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Imagine than padfX[0] = 0.5 and padfY[0] = 0.5 (so center of the top left pixel)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">which will lead to iX = 0 and iY = 10<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Now we are going to take a bilinear resampling at lines 788-800 (current trunk)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">out_padfX[0] = 0.25 * (geoloc[0] + geoloc[1] + geoloc[width] + geoloc[width+1])<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">whereas it should be just out_padfX[0] = geoloc[0] . No resampling needed.<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">So perhaps something like the following ( substracting 0.5 ) would work ?<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">const double dfGeoLocPixel =<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">(padfX[i] - 0.5 - psTransform->dfPIXEL_OFFSET)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">/ psTransform->dfPIXEL_STEP;<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">const double dfGeoLocLine =<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">(padfY[i] - 0.5 - psTransform->dfLINE_OFFSET)<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">/ psTransform->dfLINE_STEP;<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">and probably something equivalent in the other direction<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Perhaps we should have some metadata item to indicate the convention and apply or not this 0.5 shift<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Like GEOLOC_COORD_CONVENTION=PIXEL_CENTER (default if not specified) or GEOLOC_COORD_CONVENTION=PIXEL_TOP_LEFT<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">But I'd expect most (all ?) datasources to use a pixel_center convention.<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Which format/driver are you using ?<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0">
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">--
<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">Spatialys - Geospatial professional services<o:p></o:p></p>
<p style="margin:0in;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0">http://www.spatialys.com<o:p></o:p></p>
</div>
</body>
</html>