[gdal-dev] Re: Proposal: gdal_muladd.py

Antonio Valentino antonio.valentino at tiscali.it
Tue Feb 2 06:39:49 EST 2010


Hi Andrew,

Il giorno Tue, 02 Feb 2010 10:43:27 -0000
"Andrew Brooks" <arb at sat.dundee.ac.uk> ha scritto:

> Hi Antonio
> 
> Your pixel function patch sounds interesting.  I've not tried it yet,

thanks 

> but how easy is it to create a stack of functions? For example if
> absdiff(b1.tif,b2.tif) is not available how would I create
> abs(diff(b1.tif,b2.tif)) ?

the idea is to write a command line tool (or a GUI one) that analyzes 
the algebric expression an produces the the appropriate stack of
virtual files.

I have still not written such a tool.

If you want simply to give it a try you could do something like the
following (not tested):

$ echo diff.vrt
<VRTDataset rasterXSize="5" rasterYSize="6">
  <VRTRasterBand dataType="CFloat32" band="1"
subClass="VRTDerivedRasterBand"> <Description>Difference</Description>
    <PixelFunctionType>diff</PixelFunctionType>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
      <DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
    </SimpleSource>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">cfloat64.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
      <DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

$ echo abs.vrt
<VRTDataset rasterXSize="5" rasterYSize="6">
  <VRTRasterBand dataType="Byte" band="1"
subClass="VRTDerivedRasterBand"> <Description>Abs</Description>
    <PixelFunctionType>mod</PixelFunctionType>
    <SourceTransferType>CFloat32</SourceTransferType>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">diff.vrt</SourceFilename>
      <SourceBand>1</SourceBand>
      <SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
      <DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

$ gdal_translate abs.vrt absdiff.tif

Uses band 1 from cint_sar.tif and cfloat64.tif of the test dataset.

Note that if you use ComplexSource instead of SimpleSource you can also
apply a scaling factor.

Writing simple vrt file is not hard but if the expression is complex it
could be quite boring.

Does the example answerer your question?

best regards

-- 
Antonio Valentino


More information about the gdal-dev mailing list