svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src-test / org / gvsig / remotesensing / processtest / TPCStatisticProcess.java @ 17860
History | View | Annotate | Download (3.32 KB)
1 |
package org.gvsig.remotesensing.processtest; |
---|---|
2 |
|
3 |
import junit.framework.TestCase; |
4 |
|
5 |
import org.gvsig.raster.RasterLibrary; |
6 |
import org.gvsig.raster.buffer.BufferFactory; |
7 |
import org.gvsig.raster.buffer.RasterBufferInvalidException; |
8 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
9 |
import org.gvsig.raster.dataset.RasterDataset; |
10 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
11 |
import org.gvsig.raster.grid.Grid; |
12 |
import org.gvsig.remotesensing.principalcomponents.PCStatisticsProcess; |
13 |
|
14 |
import Jama.Matrix; |
15 |
|
16 |
|
17 |
/**
|
18 |
* Este test prueba el proceso de calculo de las matriz de autovectores de la
|
19 |
* imagen "PCA_bouldr_tm_int16.img", de seis bandas.
|
20 |
* Los elementos de la matriz obtenida en el proceso se comparan en valor absoluto
|
21 |
* comparan con los elementos de la matriz de autovalores proporcionada por ERDAS.
|
22 |
* ** @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
23 |
* */
|
24 |
|
25 |
public class TPCStatisticProcess extends TestCase { |
26 |
|
27 |
/*private String baseDir = "./test-images/";
|
28 |
private String path1 = baseDir + "bouldr_tm_Int16.dat";
|
29 |
private RasterDataset f1 = null;
|
30 |
private BufferFactory ds1 = null;
|
31 |
|
32 |
|
33 |
static{
|
34 |
RasterLibrary.wakeUp();
|
35 |
}
|
36 |
|
37 |
public void start() {
|
38 |
this.setUp();
|
39 |
this.testStack();
|
40 |
}
|
41 |
|
42 |
public void setUp() {
|
43 |
System.err.println("TPCStatisticProcess running...");
|
44 |
try {
|
45 |
f1 = RasterDataset.open(null, path1);
|
46 |
} catch (NotSupportedExtensionException e) {
|
47 |
e.printStackTrace();
|
48 |
} catch (RasterDriverException e) {
|
49 |
// TODO Auto-generated catch block
|
50 |
e.printStackTrace();
|
51 |
}
|
52 |
ds1 = new BufferFactory(f1);
|
53 |
|
54 |
}
|
55 |
|
56 |
public void testStack() {
|
57 |
|
58 |
// Matriz de autovectores obtenida con ERDAS
|
59 |
double autoVectorMatrixERDAS[][] = {
|
60 |
{0.4467930765462516 ,-0.2132448427522436, 0.61999384198935, 0.5583203571234574 ,0.1212877203683758 ,0.2099473443357927 },
|
61 |
{0.2302721175129133 ,-0.06284659594556273, 0.2921484644686843 ,-0.1714351492532642, -0.09649740387440189 ,-0.9049710341330732},
|
62 |
{0.287184731205834, 0.07705684070022263, 0.3977736576013743, -0.7037344497503186, -0.351412521922381 ,0.3669200927798035},
|
63 |
{0.3884643668946926, -0.7858370140117444 ,-0.408108215862561 ,-0.2060071443748747 ,0.1431802274591002, 0.04542891295109729},
|
64 |
{0.6376828181240171, 0.4126887053417631, -0.451856773747645, 0.2418214698550539, -0.4001988234001318, -0.01540747915579309},
|
65 |
{0.3276151521697355 ,0.3959638943275853 ,-0.0361409474886444, -0.2504588305907446 ,0.8196505984901843 ,0.004243695755382132}
|
66 |
};
|
67 |
|
68 |
Grid g=null;
|
69 |
try {
|
70 |
g = new Grid(ds1);
|
71 |
} catch (RasterBufferInvalidException e) {
|
72 |
e.printStackTrace();
|
73 |
}
|
74 |
|
75 |
PCStatisticsProcess sProcess= new PCStatisticsProcess(ds1.getDataSource(),null,new boolean[]{true,true,true,true,true,true});
|
76 |
sProcess.calculate();
|
77 |
Matrix autoV=sProcess.getAutoVectorMatrix();
|
78 |
// Reordenamos en orden descencente del valor de los autovectores
|
79 |
int resultOrden[]= new int[autoV.getRowDimension()];
|
80 |
int cont = autoV.getRowDimension()-1;
|
81 |
for(int i=0;i<autoV.getRowDimension();i++){
|
82 |
resultOrden[i]=cont;
|
83 |
cont--;
|
84 |
}
|
85 |
|
86 |
*//**La comparacion se realiza en valor absoluto, ya que el criterio de signos puede variar*//* |
87 |
for(int i=0; i<autoVectorMatrixERDAS.length;i++)
|
88 |
for(int j=0;j<autoVectorMatrixERDAS[0].length;j++)
|
89 |
{
|
90 |
assertEquals(java.lang.Math.abs(autoVectorMatrixERDAS[i][j]), java.lang.Math.abs(autoV.get(i, resultOrden[j])), 0.005);
|
91 |
}
|
92 |
|
93 |
}
|
94 |
*/
|
95 |
|
96 |
|
97 |
|
98 |
} |