[GRASS-SVN] r66751 - grass-addons/grass7/imagery/i.spec.sam
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Nov 5 10:46:49 PST 2015
Author: ychemin
Date: 2015-11-05 10:46:49 -0800 (Thu, 05 Nov 2015)
New Revision: 66751
Modified:
grass-addons/grass7/imagery/i.spec.sam/main.c
grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
Log:
spectral angle fixed, singularity is problem now
Modified: grass-addons/grass7/imagery/i.spec.sam/main.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/main.c 2015-11-05 18:25:54 UTC (rev 66750)
+++ grass-addons/grass7/imagery/i.spec.sam/main.c 2015-11-05 18:46:49 UTC (rev 66751)
@@ -42,7 +42,6 @@
vec_struct *b, *Avector;
int matrixsize;
-float curr_angle;
struct Ref Ref;
@@ -59,7 +58,7 @@
char *result_prefix;
mat_struct *open_files(char * matrixfile, char *img_grp);
-void spectral_angle();
+float spectral_angle();
CELL myround(double x);
int main(int argc,char * argv[])
@@ -78,6 +77,7 @@
mat_struct *A; /*first use in open.c G_matrix_set()*/
char *group;
+ float spectangle; /*numerical value of the spectral angle*/
G_gisinit (argv[0]);
@@ -126,8 +126,8 @@
if (j !=i)
{
b = G_matvect_get_row(A, j); /* compare with next col in A */
- spectral_angle();
- anglefield[i][j]= curr_angle;
+ spectangle = spectral_angle(b, Avector);
+ anglefield[i][j]= spectangle;
G_vector_free(b);
}
}
@@ -199,8 +199,8 @@
for (i = 0; i < Ref.nfiles; i++) /* Ref.nfiles = matrixsize*/
{
Avector = G_matvect_get_row(A, i); /* go row-wise through matrix*/
- spectral_angle();
- result_cell[i][col] = myround (curr_angle);
+ spectangle = spectral_angle(Avector, b);
+ result_cell[i][col] = myround (spectangle);
G_vector_free(Avector);
}
G_vector_free(b);
Modified: grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/spec_angle.c 2015-11-05 18:25:54 UTC (rev 66750)
+++ grass-addons/grass7/imagery/i.spec.sam/spec_angle.c 2015-11-05 18:46:49 UTC (rev 66751)
@@ -38,11 +38,16 @@
/* Measure spectral angle */
/* multiply one A column with second */
- vtmp1 = G_vector_init (Avector1->rows, Avector1->rows, CVEC);
+ vtmp1 = G_vector_init (Avector1->cols, Avector1->cols, RVEC);
+ G_message("sa1");
vtmp1 = G_vector_product(Avector1, Avector2,vtmp1);
+ G_message("sa2");
norm1 = G_vector_norm1(vtmp1); /* calculate 1-norm */
+ G_message("sa3");
norm2 = G_vector_norm_euclid(Avector1); /* calculate 2-norm (Euclidean) */
+ G_message("sa4");
norm3 = G_vector_norm_euclid(Avector2); /* calculate 2-norm (Euclidean) */
+ G_message("sa5");
G_vector_free(vtmp1);
More information about the grass-commit
mailing list