Browse Source

i.segment: prepare for different algorithms

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68468 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 9 years ago
parent
commit
13193822a6

File diff suppressed because it is too large
+ 2 - 1557
imagery/i.segment/create_isegs.c


+ 10 - 2
imagery/i.segment/iseg.h

@@ -33,6 +33,7 @@ struct rclist
     struct rc *tail, *head;
 };
 
+
 /* input and output files, as well as some other processing info */
 struct globals
 {
@@ -40,7 +41,7 @@ struct globals
     char *image_group;
     int weighted;		/* 0 if false/not selected, so we should scale input.
 				 * 1 if the scaling should be skipped */
-    int method;			/* Segmentation method */
+    int (*method)();		/* Segmentation method function */
     int nn;			/* number of neighbors, 4 or 8 */
     double max_diff;		/* max possible difference */
     double alpha;		/* similarity threshold */
@@ -104,7 +105,6 @@ int open_files(struct globals *);
 
 /* create_isegs.c */
 int create_isegs(struct globals *);
-int region_growing(struct globals *);
 void find_four_neighbors(int, int, int[][2]);
 void find_eight_neighbors(int, int, int[8][2]);
 double calculate_euclidean_similarity(struct ngbr_stats *, 
@@ -122,6 +122,14 @@ int update_band_vals(int, int, struct reg_stats *, struct globals *);
 /* void calculate_reg_stats(int, int, struct reg_stats *, 
                          struct globals *); */
 
+/* region_growing.c */
+int region_growing(struct globals *);
+
+/* mean_shift.c */
+int mean_shift(struct globals *);
+
+/* watershed.c */
+int watershed(struct globals *);
 
 /* rclist.c */
 void rclist_init(struct rclist *);

+ 22 - 0
imagery/i.segment/mean_shift.c

@@ -0,0 +1,22 @@
+/* PURPOSE:      Develop the image segments */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <float.h>
+#include <math.h>
+#include <time.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include <grass/raster.h>
+#include <grass/segment.h>	/* segmentation library */
+#include <grass/rbtree.h>	/* Red Black Tree library functions */
+#include "iseg.h"
+
+int mean_shift(struct globals *globals)
+{
+    G_fatal_error(_("Mean shift is not yet implemented"));
+    
+    return FALSE;
+}
+

+ 7 - 3
imagery/i.segment/parse_args.c

@@ -37,7 +37,7 @@ int parse_args(int argc, char *argv[], struct globals *globals)
     method->type = TYPE_STRING;
     method->required = NO;
     method->answer = "region_growing";
-    method->options = "region_growing";
+    method->options = "region_growing,mean_shift,watershed";
     method->description = _("Segmentation method");
     method->guisection = _("Settings");
 
@@ -154,11 +154,15 @@ int parse_args(int argc, char *argv[], struct globals *globals)
 
     /* segmentation methods:  1 = region growing */
     if (strcmp(method->answer, "region_growing") == 0)
-	globals->method = 1;
+	globals->method = region_growing;
+    if (strcmp(method->answer, "mean_shift") == 0)
+	globals->method = mean_shift;
+    if (strcmp(method->answer, "watershed") == 0)
+	globals->method = watershed;
     else
 	G_fatal_error(_("Unable to assign segmentation method"));
 
-    G_debug(1, "segmentation method: %d", globals->method);
+    G_debug(1, "segmentation method: %s", method->answer);
 
     /* distance methods for similarity measurement */
     if (strcmp(similarity->answer, "euclidean") == 0)

File diff suppressed because it is too large
+ 1567 - 0
imagery/i.segment/region_growing.c


+ 23 - 0
imagery/i.segment/watershed.c

@@ -0,0 +1,23 @@
+/* PURPOSE:      Develop the image segments */
+
+/* Currently only region growing is implemented */
+
+#include <stdlib.h>
+#include <string.h>
+#include <float.h>
+#include <math.h>
+#include <time.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include <grass/raster.h>
+#include <grass/segment.h>	/* segmentation library */
+#include <grass/rbtree.h>	/* Red Black Tree library functions */
+#include "iseg.h"
+
+int watershed(struct globals *globals)
+{
+    G_fatal_error(_("Watershed is not yet implemented"));
+    
+    return FALSE;
+}
+