svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src-test / org / gvsig / remotesensing / processtest / TPCImageProcess.java @ 21677
History | View | Annotate | Download (4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Iba?ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
34 |
* Campus Universitario s/n
|
35 |
* 02071 Alabacete
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 967 599 200
|
39 |
*/
|
40 |
|
41 |
package org.gvsig.remotesensing.processtest; |
42 |
|
43 |
import junit.framework.TestCase; |
44 |
|
45 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
46 |
import org.gvsig.raster.RasterLibrary; |
47 |
import org.gvsig.raster.buffer.BufferFactory; |
48 |
import org.gvsig.raster.buffer.RasterBufferInvalidException; |
49 |
import org.gvsig.raster.dataset.IBuffer; |
50 |
import org.gvsig.raster.grid.Grid; |
51 |
import org.gvsig.remotesensing.principalcomponents.PCImageProcess; |
52 |
|
53 |
import Jama.Matrix; |
54 |
|
55 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
56 |
|
57 |
|
58 |
/**
|
59 |
* Este test prueba el proceso de construcci?n de la imagen resultante del proceso
|
60 |
* de analisis de componentes principales de la imagen pc_CreateImageTest.tif de
|
61 |
* dimensiones 4x4 y tres bandas.
|
62 |
*
|
63 |
* ** @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
64 |
* */
|
65 |
public class TPCImageProcess extends TestCase { |
66 |
|
67 |
private String baseDir = "./test-images/"; |
68 |
private String path1 = baseDir + "pc_CreateImageTest.tif"; |
69 |
FLyrRasterSE lyr = null;
|
70 |
Grid dataGrid=null;
|
71 |
IBuffer result= null;
|
72 |
|
73 |
static{
|
74 |
RasterLibrary.wakeUp(); |
75 |
} |
76 |
|
77 |
public void start() { |
78 |
this.setUp();
|
79 |
this.testStack();
|
80 |
} |
81 |
|
82 |
public void setUp() { |
83 |
try {
|
84 |
lyr = FLyrRasterSE.createLayer( |
85 |
path1, |
86 |
path1, |
87 |
null
|
88 |
); |
89 |
BufferFactory ds1 = new BufferFactory(lyr.getDataSource());
|
90 |
dataGrid= new Grid(ds1);
|
91 |
|
92 |
} catch (LoadLayerException e) {
|
93 |
System.out.print("Error en la construcci?n de la capa"); |
94 |
} catch (RasterBufferInvalidException e) {
|
95 |
e.printStackTrace(); |
96 |
} |
97 |
} |
98 |
|
99 |
public void testStack() { |
100 |
|
101 |
PCImageProcess iProcess = new PCImageProcess ();
|
102 |
iProcess.addParam("layer",lyr);
|
103 |
iProcess.addParam("grid",dataGrid);
|
104 |
iProcess.addParam("autovalores",new double[]{425.104,1753.227,18714.369}); |
105 |
iProcess.addParam("autovectores", new Matrix(new double[][]{{-0.922766631036,0.2990630039783, 0.2430289371596}, |
106 |
{-0.030678162029,-0.685664096085, 0.7272713370632}, |
107 |
{0.3841361672896,0.6636460404393, 0.6418826512605}})); |
108 |
iProcess.addParam("compselected",new boolean[]{true,true,true}); |
109 |
iProcess.run(); |
110 |
result=iProcess.getBufferResult(); |
111 |
compare(); |
112 |
} |
113 |
|
114 |
private void compare() { |
115 |
|
116 |
// Mismo numero de bandas
|
117 |
assertEquals(result.getBandCount(),3);
|
118 |
|
119 |
//Comparaci?n de valores
|
120 |
assertEquals(result.getElemFloat(0, 0,0),1977.6109,1); |
121 |
assertEquals(result.getElemFloat(0, 1,0),1864.9603,1); |
122 |
assertEquals(result.getElemFloat(0, 2,0),1896.0991,1); |
123 |
assertEquals(result.getElemFloat(0, 3,0),1768.2855,1); |
124 |
|
125 |
assertEquals(result.getElemFloat(1, 0,0),2081.7544,1); |
126 |
assertEquals(result.getElemFloat(1, 1,0),2062.1047,1); |
127 |
assertEquals(result.getElemFloat(1, 2,0),1989.8268,1); |
128 |
assertEquals(result.getElemFloat(1, 3,0),1777.2758,1); |
129 |
|
130 |
// Completar con resultado de otras dos bandas
|
131 |
} |
132 |
} |