svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / statistics / TailTrimByteFilter.java @ 11714
History | View | Annotate | Download (3.03 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.grid.filter.statistics; |
20 |
|
21 |
import org.gvsig.raster.dataset.IBuffer; |
22 |
import org.gvsig.raster.dataset.Params; |
23 |
|
24 |
/**
|
25 |
* Proceso del filtro de recorte de colas aplicado al tipo de datos byte
|
26 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
27 |
*
|
28 |
*/
|
29 |
public class TailTrimByteFilter extends TailTrimFilter { |
30 |
|
31 |
/**
|
32 |
* Array con el resultado. La primera dimensi?n es el n?mero de bandas y la segunda son dos elementos
|
33 |
* el m?ximo y el m?nimo para esa banda.
|
34 |
*/
|
35 |
private double[][] result = null; |
36 |
|
37 |
public TailTrimByteFilter() {
|
38 |
} |
39 |
|
40 |
/**
|
41 |
* Obtiene par?metros para el filtro y obtiene el ancho y alto de
|
42 |
* la imagen sobre la que se aplica el filtro
|
43 |
*/
|
44 |
public void pre() { |
45 |
super.pre();
|
46 |
sample = new int[raster.getBandCount()][nSamples]; |
47 |
result = new double[raster.getBandCount()][2]; |
48 |
} |
49 |
|
50 |
/**
|
51 |
* Carga sobre el vector de muestras los valores de estas cogidos
|
52 |
* de la imagen
|
53 |
*/
|
54 |
public void process(int col, int line) { |
55 |
for(int iBand = 0 ; iBand < raster.getBandCount() ; iBand ++) |
56 |
sample[iBand][count] = raster.getElemByte(line, col, iBand); |
57 |
count++; |
58 |
} |
59 |
|
60 |
/* (non-Javadoc)
|
61 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
62 |
*/
|
63 |
public int getInRasterDataType() { |
64 |
return IBuffer.TYPE_BYTE;
|
65 |
} |
66 |
|
67 |
/* (non-Javadoc)
|
68 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
69 |
*/
|
70 |
public int getOutRasterDataType() { |
71 |
return IBuffer.TYPE_BYTE;
|
72 |
} |
73 |
|
74 |
/* (non-Javadoc)
|
75 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
76 |
*/
|
77 |
public void post() { |
78 |
super.post();
|
79 |
|
80 |
//Ordenamos los elementos y cogemos el minimo y m?ximo para cada banda
|
81 |
for (int i = 0; i < raster.getBandCount(); i++) { |
82 |
result[i][0] = sample[i][posInit + tailSize];
|
83 |
result[i][1] = sample[i][(posInit + nSamples) - tailSize - 1]; |
84 |
} |
85 |
stats.setTailTrimValue(tailPercent, result); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* Obtiene el objeto con el m?ximo y m?nimo calculado
|
90 |
*/
|
91 |
public Object getResult(String name) { |
92 |
if (name.equals("raster")) |
93 |
return (Object) this.raster; |
94 |
else
|
95 |
return result;
|
96 |
} |
97 |
} |