Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avalentino committed Apr 13, 2014
0 parents commit cceed0b
Show file tree
Hide file tree
Showing 44 changed files with 4,904 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.c
*.pyc
*.o
*.so
*~
17 changes: 17 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
##############################################################################
#
# Project: GDAL
# Purpose: Implementation of a set of GDALDerivedPixelFunc(s) to be used
# with source raster band of virtual GDAL datasets.
# Author: Antonio Valentino <antonio.valentino@tiscali.it>
#
##############################################################################
# Copyright (c) 2008-2014 Antonio Valentino <antonio.valentino@tiscali.it>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
##############################################################################

.PHONY: all clean dist

OBJS = pixfunplugin.o pixelfunctions.o
CFLAGS := -fPIC -Wall -Wno-long-long $(shell gdal-config --cflags) $(CFLAGS)
CFLAGS := -pedantic $(CFLAGS)

CFLAGS := -g $(CFLAGS)
#CFLAGS := -O3 $(CFLAGS)

TARGET = gdal_PIXFUN.so

all: $(TARGET)

clean:
$(RM) $(TARGET) *.o *~
$(RM) autotest/pymod/*.pyc autotest/gcore/*.pyc

$(TARGET): $(OBJS)
$(CC) -shared -o $@ $(OBJS) $(shell gdal-config --libs)


PYTHON=python

check:
cd autotest/gcore && \
env GDAL_DRIVER_PATH=$(PWD):$(GDAL_DRIVER_PATH) \
PYTHONPATH=$(PWD)/autotest/pymod:$(PYTHONPATH) \
$(PYTHON) pixfun.py
83 changes: 83 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
gdal-pixfun-plugin
==================

A small gdal plugin that provides a small set of "pixel functions" (see
http://www.gdal.org/gdal_vrttut.html) that can be used to create derived
raster bands.


List of pixel functions
-----------------------

:"real":
extract real part from a single raster band (just a copy if the
input is non-complex)
:"imag":
extract imaginary part from a single raster band (0 for
non-complex)
:"mod":
extract module from a single raster band (real or complex)
:"phase":
extract phase from a single raster band (0 for non-complex)
:"conj":
computes the complex conjugate of a single raster band (just a
copy if the input is non-complex)
:"sum":
sum 2 or more raster bands
:"diff":
computes the difference between 2 raster bands (b1 - b2)
:"mul":
multilpy 2 or more raster bands
:"cmul":
multiply the first band for the complex conjugate of the second
:"inv":
inverse (1./x). Note: no check is performed on zero division
:"intensity":
computes the intensity Re(x*conj(x)) of a single raster band
(real or complex)
:"sqrt":
perform the square root of a single raster band (real only)
:"log10":
compute the logarithm (base 10) of the abs of a single raster
band (real or complex): log10( abs( x ) )
:"dB2amp":
perform scale conversion from logarithmic to linear
(amplitude) (i.e. 10 ^ ( x / 20 ) ) of a single raster band (real only)
:"dB2pow":
perform scale conversion from logarithmic to linear
(power) (i.e. 10 ^ ( x / 10 ) ) of a single raster band (real only)


How to get it
-------------

The project home page is at https://github.com/avalentino/gdal-pixfun-plugin.
A copy of the latest version of the sources can be obtained ising git_::

$ git clone https://github.com/avalentino/gdal-pixfun-plugin.git

.. _git: http://git-scm.com


How to build, test and install
-----------------------------

The gdal-pixfun-plugin can be built using the following command::

$ make

in the root folder of the source distribution.
It assumes that GDAL is correctly installed on your system.

To run the unit test suite::

$ make check

To install the plugin just copy the generated shared object (gdal_PIXFUN.so)
into the GDAL plugin directory (/usr/lib/gdalplugins/1.XX/ on unix).


License
-------

See the LICENSE.txt file.
Binary file added autotest/gcore/data/cfloat64.tif
Binary file not shown.
Binary file added autotest/gcore/data/cint_sar.tif
Binary file not shown.
Binary file added autotest/gcore/data/float32.tif
Binary file not shown.
Binary file added autotest/gcore/data/int32.tif
Binary file not shown.
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_cmul_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CFloat32" band="1" subClass="VRTDerivedRasterBand">
<Description>Product with complex conjugate</Description>
<PixelFunctionType>cmul</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">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>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_cmul_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Product with complex conjugate</Description>
<PixelFunctionType>cmul</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">uint16.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_conj_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CInt16" band="1" subClass="VRTDerivedRasterBand">
<Description>conjugate</Description>
<PixelFunctionType>conj</PixelFunctionType>
<SourceTransferType>CInt16</SourceTransferType>
<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>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_conj_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>conjugate</Description>
<PixelFunctionType>conj</PixelFunctionType>
<SourceTransferType>Int32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_dB2amp.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>db to amplitude</Description>
<PixelFunctionType>dB2amp</PixelFunctionType>
<SourceTransferType>Float64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_dB2pow.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>dB to power</Description>
<PixelFunctionType>dB2pow</PixelFunctionType>
<SourceTransferType>Float64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_diff_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<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>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_diff_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Difference</Description>
<PixelFunctionType>diff</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.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">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="10" yOff="10" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_imag_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>Imaginary part</Description>
<PixelFunctionType>imag</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<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>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_imag_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Imaginary part</Description>
<PixelFunctionType>imag</PixelFunctionType>
<SourceTransferType>Float32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_intensity_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>Intensity</Description>
<PixelFunctionType>intensity</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<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>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_intensity_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Intensity</Description>
<PixelFunctionType>intensity</PixelFunctionType>
<SourceTransferType>Float32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_inv_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CFloat64" band="1" subClass="VRTDerivedRasterBand">
<Description>Inverse</Description>
<PixelFunctionType>inv</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<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>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_inv_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>Inverse</Description>
<PixelFunctionType>inv</PixelFunctionType>
<SourceTransferType>Float64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_log10.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Log10</Description>
<PixelFunctionType>log10</PixelFunctionType>
<SourceTransferType>Float32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
Loading

0 comments on commit cceed0b

Please sign in to comment.