This is an automated email from the git hooks/post-receive script. sebastic-guest pushed a commit to branch upstream-master in repository pktools.
commit 0df665d75d3397463186c59f6fa07e3ffc0437d6 Author: Pieter Kempeneers <kempe...@gmail.com> Date: Sun Sep 21 11:46:47 2014 -0700 working on filter in spectral domain --- ChangeLog | 2 ++ doc/examples_pkextract.dox | 33 +++++++++++++++++++-------------- src/algorithms/Filter.cc | 13 ++++++++++--- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbbe5ae..38c5595 100755 --- a/ChangeLog +++ b/ChangeLog @@ -308,6 +308,8 @@ version 2.5.3 version 2.5.4 - pkinfo Support multiple input bands when calculating statistics + - pkfilter + Support filtering and statistics in spectral domain (see ticket #43252) Next versions: - todo for API: ImgReaderGdal (ImgWriterGdal) open in update mode (check gdal_edit.py: http://searchcode.com/codesearch/view/18938404) diff --git a/doc/examples_pkextract.dox b/doc/examples_pkextract.dox index f9a0f51..0ba5b51 100644 --- a/doc/examples_pkextract.dox +++ b/doc/examples_pkextract.dox @@ -1,37 +1,42 @@ \section examples_pkextract Examples of pkextract \code -pkextract -i input.tif -s points.shp -o extracted.shp +pkextract -i input.tif -s points.sqlite -o extracted.sqlite \endcode -extract the points read in points.shp from input.tif. Create a new point vector file extracted.shp, where each point will contain an attribute for the individual input bands in input.tif. +extract the points read in points.sqlite from input.tif. Create a new point vector file extracted.sqlite, where each point will contain an attribute for the individual input bands in input.tif. \code -pkextract -i input.tif -s points.shp -m mask.tif -msknodata 255 -o extracted.shp +pkextract -i input.tif -s points.shp -f "ESRI Shapefile" -o extracted.shp \endcode -extract all bands from input.tif to extracted.shp at pixel locations defined in points.shp that have not a value 255 in mask.tif +Same example as above, but vector format is ESRI Shapefile \code -pkextract -i input.tif -s polygons.shp -o training.shp -r point +pkextract -i input.tif -s points.sqlite -m mask.tif -msknodata 255 -o extracted.sqlite \endcode -extract all pixels from input.tif covered by the polygons in locations.shp. Each polygon can thus result in multiple point features with attributes for each input band. Write the extracted points to a point vector file training.shp. +extract all bands from input.tif to extracted.sqlite at pixel locations defined in points.sqlite that have not a value 255 in mask.tif \code -pkextract -i input.tif -b 0 -s polygons.shp -r centroid -o extracted.shp -polygon +pkextract -i input.tif -s polygons.sqlite -o training.sqlite -r point \endcode -extract the first band from input.tif at the centroids of the polygons in vector filepolygons.shp. Assign the extracted point value to a new attribute of the polygon and write to the vector file extracted.shp. +extract all pixels from input.tif covered by the polygons in locations.sqlite. Each polygon can thus result in multiple point features with attributes for each input band. Write the extracted points to a point vector file training.sqlite. \code -pkextract -i input.tif -b 1 -s polygons.shp -r mean -o extracted.shp -polygon +pkextract -i input.tif -b 0 -s polygons.sqlite -r centroid -o extracted.sqlite -polygon \endcode -extract the mean values for the second band in input.tif covered by each polygon in polygons.shp. The mean values are written to a copy of the polygons in output vector file extracted.shp +extract the first band from input.tif at the centroids of the polygons in vector filepolygons.sqlite. Assign the extracted point value to a new attribute of the polygon and write to the vector file extracted.sqlite. \code -pkextract -i input.tif -s sample.tif -o extracted.shp -t 10 -c 1 -c 2 -c 3 +pkextract -i input.tif -b 1 -s polygons.sqlite -r mean -o extracted.sqlite -polygon \endcode -Typical use where pixels are extracted based on a land cover map (sample.tif). Extract all bands for a random sample of 10 percent of the pixels in the land cover map sample.tif where the land cover classes are either 1,2 or 3 (class values). Write output to the point vector file extracted.shp. +extract the mean values for the second band in input.tif covered by each polygon in polygons.sqlite. The mean values are written to a copy of the polygons in output vector file extracted.sqlite \code -pkextract -i input.tif -s sample.tif -o extracted.shp -t -5000 -c 1 +pkextract -i input.tif -s sample.tif -o extracted.sqlite -t 10 -c 1 -c 2 -c 3 \endcode -extract all bands for the first 5000 pixels encountered in sample.tif where pixels have a value equal to 1. Write output to point vector file extracted.shp. +Typical use where pixels are extracted based on a land cover map (sample.tif). Extract all bands for a random sample of 10 percent of the pixels in the land cover map sample.tif where the land cover classes are either 1,2 or 3 (class values). Write output to the point vector file extracted.sqlite. + +\code +pkextract -i input.tif -s sample.tif -o extracted.sqlite -t -5000 -c 1 +\endcode +extract all bands for the first 5000 pixels encountered in sample.tif where pixels have a value equal to 1. Write output to point vector file extracted.sqlite. diff --git a/src/algorithms/Filter.cc b/src/algorithms/Filter.cc index 58080bd..ee48822 100644 --- a/src/algorithms/Filter.cc +++ b/src/algorithms/Filter.cc @@ -338,10 +338,14 @@ void filter::Filter::stat(const ImgReaderGdal& input, ImgWriterGdal& output, con double progress=0; pfnProgress(progress,pszMessage,pProgressArg); for(int y=0;y<input.nrOfRow();++y){ + if((y+1+down/2)%down) + continue; for(int iband=0;iband<input.nrOfBand();++iband) input.readData(lineInput[iband],GDT_Float64,y,iband); vector<double> pixelInput(input.nrOfBand()); for(int x=0;x<input.nrOfCol();++x){ + if((x+1+down/2)%down) + continue; pixelInput=lineInput.selectCol(x); switch(getFilterType(method)){ case(filter::median): @@ -354,11 +358,14 @@ void filter::Filter::stat(const ImgReaderGdal& input, ImgWriterGdal& output, con lineOutput[(x-offset+down-1)/down]=stat.mymax(pixelInput); break; case(filter::sum): - lineOutput[(x-offset+down-1)/down]=sqrt(stat.sum(pixelInput)); + lineOutput[(x-offset+down-1)/down]=stat.sum(pixelInput); break; case(filter::var): lineOutput[(x-offset+down-1)/down]=stat.var(pixelInput); break; + case(filter::stdev): + lineOutput[(x-offset+down-1)/down]=sqrt(stat.var(pixelInput)); + break; case(filter::mean): lineOutput[(x-offset+down-1)/down]=stat.mean(pixelInput); break; @@ -369,10 +376,10 @@ void filter::Filter::stat(const ImgReaderGdal& input, ImgWriterGdal& output, con } } try{ - output.writeData(lineOutput,GDT_Float64,y); + output.writeData(lineOutput,GDT_Float64,y/down); } catch(string errorstring){ - cerr << errorstring << "in line " << y << endl; + cerr << errorstring << "in line " << y/down << endl; } progress=(1.0+y)/output.nrOfRow(); pfnProgress(progress,pszMessage,pProgressArg); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel