[gdal-dev] The "Magic" kernel

Jukka Rahkonen jukka.rahkonen at maanmittauslaitos.fi
Mon Oct 19 07:44:13 PDT 2015


Graeme B. Bell <graeme.bell <at> nibio.no> writes:

> 
> http://johncostella.webs.com/magic/
> 
> I came across this article recently. Is this available as a resampling
kernel in GDAL? It looks very
> interesting. 

Unfortunately I do not understand the mathematics of the {1/4, 3/4, 3/4,
1/4} kernel but if there is a way to turn this "magic" kernel into odd
kernel (odd as an opposite to even) you can use GDAL VRT.
http://cbloomrants.blogspot.fi/2011/03/03-24-11-image-filters-and-gradients.html
perhaps suggests that it is possible. GDAL KernelFilteredSource accepts only
odd filters.

I copy here an example about how to make GDAL to support the 5x5 unsharp
kernel https://en.wikipedia.org/wiki/Kernel_%28image_processing%29 

</VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <ColorInterp>Green</ColorInterp>
    <KernelFilteredSource>
      <SourceFilename relativeToVRT="1">unsharp_filter_test.tif</SourceFilename>
      <SourceBand>2</SourceBand>
        <Kernel normalized="1">
          <Size>5</Size>
          <Coefs>1 4 6 4 1 4 16 24 16 4 6 24 -476 24 6 4 16 24 16 4 1 4 6 4
1</Coefs>
        </Kernel>
    </KernelFilteredSource>
</VRTRasterBand>

VRT works fine in QGIS and I can't notice any speed difference with
unfiltered image.


-Jukka Rahkonen-






More information about the gdal-dev mailing list