[gimp-gap] added foreground extract from selection



commit dd2d1f27dda5d98deed6ae5c7f2231c0f0a1bd07
Author: Wolfgang Hofer <wolfgangh svn gnome org>
Date:   Wed Nov 23 17:44:04 2011 +0100

    added foreground extract from selection

 ChangeLog                                          |   20 +
 docs/reference/txt/Makefile.am                     |    1 +
 .../txt/plug-in-selection-to-foreground-layer.txt  |   74 ++++
 gap/Makefile.am                                    |    4 +-
 gap/gap_fg_from_sel_dialog.c                       |  461 ++++++++++++++++++++
 gap/gap_fg_from_sel_dialog.h                       |   41 ++
 gap/gap_fg_matting_exec.c                          |  145 ++++++-
 gap/gap_fg_matting_exec.h                          |    5 +
 gap/gap_fg_matting_main.c                          |  205 ++++++---
 gap/gap_fg_matting_main.h                          |   21 +-
 po/POTFILES.in                                     |    1 +
 11 files changed, 913 insertions(+), 65 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ada53e4..f185b44 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2011-11-23 Wolfgang Hofer <hof gimp org>
+
+- Foreground selection: fixed parameters for non interactive calls.
+
+- new feature: foreground extraction from current selection.
+  This feature generates the tri map by filling shrinked and expanded
+  variants of the current selection, and uses the alpha matting algoritm
+  to create a duplicate of the layer. Transparency of the duplicate
+  is automatically trimmed to the foreground object shape in the range
+  between shrinked and expanded selections variants.
+
+ * po/POTFILES.in
+ * gap/Makefile.am
+ * gap/gap_fg_matting_exec.c [.h]
+ * gap/gap_fg_matting_main.c [.h]
+ * gap/gap_fg_from_sel_dialog.c [.h]                             # new files
+ * docs/reference/txt/plug-in-selection-to-foreground-layer.txt  # new file
+ * docs/reference/txt/Makefile.am
+
+
 2011-11-12 Wolfgang Hofer <hof gimp org>
 
 - added implementation of the foreground extraction via alpha matting algorithm
diff --git a/docs/reference/txt/Makefile.am b/docs/reference/txt/Makefile.am
index 5bcf983..d10a138 100644
--- a/docs/reference/txt/Makefile.am
+++ b/docs/reference/txt/Makefile.am
@@ -45,6 +45,7 @@ EXTRA_DIST = \
 	plug-in-gap-videoframes-player.txt	\
 	plug-in-gap-xanim-decode.txt		\
 	plug-in-name2layer.txt			\
+	plug-in-selection-to-foreground-layer.txt \
 	plug-in-waterpattern.txt		\
 	plug-in-wr-color-levels.txt		\
 	plug-in-wr-curves.txt			\
diff --git a/docs/reference/txt/plug-in-selection-to-foreground-layer.txt b/docs/reference/txt/plug-in-selection-to-foreground-layer.txt
new file mode 100644
index 0000000..9b2db48
--- /dev/null
+++ b/docs/reference/txt/plug-in-selection-to-foreground-layer.txt
@@ -0,0 +1,74 @@
+"plug-in-selection-to-foreground-layer"
+
+Filter for Foreground Extraction based on Selection
+
+    Start from Menu:
+       <Image>/Layer/Transparency/Foreground Extract Via Selection
+
+How to use:
+  
+   Have an image with a foreground object loaded in GIMP
+     (for instance a person) that shall be
+     separated from the background.
+     The image shall be of RGB color
+
+   Draw a selection (for instance by using the freehand
+      selection tool)
+      The selection will be used as base for the foreground extraction
+      where the opacity and optional color of pixels near 
+      the border will be trimmed automatically.
+
+   Start the script from <Image>/Layer/Duplicate Selected Foreground.
+      This creates a new layer with the extracted foreground object
+      where the selection is automatically trimmed according
+      to matching colors.
+      It also creates a tri map (that is attached as layermask
+      to the input layer) that is internally used by the alpha matting
+      algorithm.
+   
+   
+   When your selection is drawn all inside the object,
+   you shall use inner radius 0 and set outer radius to
+   the desired width where the selection shall be trimmed.
+   
+   When your selection is drawn all outside the object,
+   you shall use outer radius 0 and set outer radius to
+   the desired width where the selection shall be trimmed.
+
+   Note:
+   If this filter is called without having a slection
+   it uses the alpha channel as implicite selection.
+   
+
+   
+Options:
+
+   InnerRadius
+      Specifies how many pixels inside the borderline of the selection
+      are considered as undefined area.
+
+   OuterRadius
+      Specifies how many pixels outside the borderline of the selection
+      are considered as undefined area.
+
+   Create Layermask
+      ON:  Render opacity by creating a new layer mask for the resulting layer
+      OFF: Apply rendered opacity to the alpha channel
+
+   Lock Colors
+      ON:  Keep RGB channels of the input layer
+      OFF: Allow Background color removal in processed undefined regions
+
+How it Works:
+   A tri-map is generated based on the current selection by setting the
+   pixels that are near the selection border to UNDEFINED state.
+   Pixels that are inside the selection and far (distance is > inner radius)
+   from the border are considered as FOREGROUND.
+   Pixels that are far (distance is > outer radius) outside the selection
+   are considered as BACKGROUND.
+   The generatated tri map is attached as layermask to the input layer.
+   This generated tri map is used to perform a foreground extraction
+   based on the alpha matting algorithm (# see plug-in-foreground-extract-matting)
+   The foreground extraction renders a new layer where transparency (and optionally color)
+   is calculated for the UNDEFINED area, FOREGROUND is rendered fully opaque
+   and BACKGROUND is rendered fully transparent.
diff --git a/gap/Makefile.am b/gap/Makefile.am
index eb4d2be..acb99ee 100644
--- a/gap/Makefile.am
+++ b/gap/Makefile.am
@@ -4,7 +4,7 @@ libexecdir = $(GIMP_PLUGIN_DIR)/plug-ins
 
 scriptdatadir = $(GIMP_DATA_DIR)/scripts
 
-scriptdata_DATA = sel-to-anim-img.scm  gap-dup-continue.scm
+scriptdata_DATA = sel-to-anim-img.scm gap-dup-continue.scm
 
 if GAP_UNIX_FRONTENDS
 GAP_FRONTENDS = gap_frontends
@@ -396,6 +396,8 @@ gap_fg_matting_SOURCES = \
 	gap_fg_matting.h	\
 	gap_fg_matting_dialog.c	\
 	gap_fg_matting_dialog.h	\
+	gap_fg_from_sel_dialog.c	\
+	gap_fg_from_sel_dialog.h	\
 	gap_fg_regions.c	\
 	gap_fg_regions.h	\
 	gap_fg_tile_manager.h
diff --git a/gap/gap_fg_from_sel_dialog.c b/gap/gap_fg_from_sel_dialog.c
new file mode 100644
index 0000000..1131fb9
--- /dev/null
+++ b/gap/gap_fg_from_sel_dialog.c
@@ -0,0 +1,461 @@
+/* gap_fg_from_sel_dialog.c
+ * 2011.11.15 hof (Wolfgang Hofer)
+ *
+ * GAP ... Gimp Animation Plugins
+ *
+ * This Module contains:
+ * - stuff for the GUI dialog
+ *   of the foreground extraction from current selection via alpha matting plug-in.
+ *
+ */
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
+
+#include "gap_fg_matting_main.h"
+#include "gap_fg_from_sel_dialog.h"
+
+#include "gap-intl.h"
+
+
+#define GAP_FOREGROUND_FROM_SELECTION_RESPONSE_RESET 1
+
+extern int gap_debug;
+#define GAP_DEBUG_DECLARED 1
+
+typedef struct _FgSelectDialogGuiStuff FgSelectDialogGuiStuff;
+
+struct _FgSelectDialogGuiStuff
+{
+  gint            run;
+  gint32          drawable_id;
+
+  GtkWidget       *shell;
+
+  GtkObject       *colordiff_innerRadius_spinbutton_adj;
+  GtkWidget       *colordiff_innerRadius_spinbutton;
+  GtkObject       *colordiff_outerRadius_spinbutton_adj;
+  GtkWidget       *colordiff_outerRadius_spinbutton;
+  GtkObject       *colordiff_threshold_spinbutton_adj;
+  GtkWidget       *colordiff_threshold_spinbutton;
+
+  GtkWidget       *lock_colorCheckbutton;
+  GtkWidget       *create_layermaskCheckbutton;
+
+
+  GapFgSelectValues *vals;
+};
+
+
+
+
+/* --------------------------------------
+ * p_update_widget_sensitivity
+ * --------------------------------------
+ */
+static void
+p_update_widget_sensitivity (FgSelectDialogGuiStuff *guiStuffPtr)
+{
+  //gtk_widget_set_sensitive(guiStuffPtr-><widget> ,                  TRUE);
+  return;
+
+}  /* end p_update_widget_sensitivity */
+
+
+/* --------------------------------------
+ * p_init_widget_values
+ * --------------------------------------
+ * update GUI widgets to reflect the current values.
+ */
+static void
+p_init_widget_values(FgSelectDialogGuiStuff *guiStuffPtr)
+{
+  if(guiStuffPtr == NULL)
+  {
+    return;
+  }
+  if(guiStuffPtr->vals == NULL)
+  {
+    return;
+  }
+
+  /* init spnbuttons */
+  gtk_adjustment_set_value(GTK_ADJUSTMENT(guiStuffPtr->colordiff_innerRadius_spinbutton_adj)
+                         , (gfloat)guiStuffPtr->vals->innerRadius);
+  gtk_adjustment_set_value(GTK_ADJUSTMENT(guiStuffPtr->colordiff_outerRadius_spinbutton_adj)
+                         , (gfloat)guiStuffPtr->vals->outerRadius);
+  gtk_adjustment_set_value(GTK_ADJUSTMENT(guiStuffPtr->colordiff_threshold_spinbutton_adj)
+                         , (gfloat)guiStuffPtr->vals->colordiff_threshold);
+
+
+  /* init checkbuttons */
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (guiStuffPtr->lock_colorCheckbutton)
+                               , guiStuffPtr->vals->lock_color);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (guiStuffPtr->create_layermaskCheckbutton)
+                               , guiStuffPtr->vals->create_layermask);
+
+
+
+}  /* end p_init_widget_values */
+
+
+/* --------------------------------------
+ * on_gboolean_button_update
+ * --------------------------------------
+ */
+static void
+on_gboolean_button_update (GtkWidget *widget,
+                           gpointer   data)
+{
+  FgSelectDialogGuiStuff *guiStuffPtr;
+  gint *toggle_val = (gint *) data;
+
+  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+  {
+    *toggle_val = TRUE;
+  }
+  else
+  {
+    *toggle_val = FALSE;
+  }
+  gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (widget));
+  
+  guiStuffPtr = (FgSelectDialogGuiStuff *) g_object_get_data (G_OBJECT (widget), "guiStuffPtr");
+  if(guiStuffPtr != NULL)
+  {
+    p_update_widget_sensitivity (guiStuffPtr);
+  }
+}
+
+
+/* ---------------------------------
+ * p_fg_from_selectiont_response
+ * ---------------------------------
+ */
+static void
+p_fg_from_selectiont_response (GtkWidget *widget,
+                 gint       response_id,
+                 FgSelectDialogGuiStuff *guiStuffPtr)
+{
+  GtkWidget *dialog;
+
+  switch (response_id)
+  {
+    case GAP_FOREGROUND_FROM_SELECTION_RESPONSE_RESET:
+      if(guiStuffPtr)
+      {
+        /* rset default values */
+        gap_fg_from_sel_init_default_vals(guiStuffPtr->vals);
+        p_init_widget_values(guiStuffPtr);
+        p_update_widget_sensitivity (guiStuffPtr);
+      }
+      break;
+
+    case GTK_RESPONSE_OK:
+      if(guiStuffPtr)
+      {
+        if (GTK_WIDGET_VISIBLE (guiStuffPtr->shell))
+        {
+          gtk_widget_hide (guiStuffPtr->shell);
+        }
+        guiStuffPtr->run = TRUE;
+      }
+
+    default:
+      dialog = NULL;
+      if(guiStuffPtr)
+      {
+        dialog = guiStuffPtr->shell;
+        if(dialog)
+        {
+          guiStuffPtr->shell = NULL;
+          gtk_widget_destroy (dialog);
+        }
+      }
+      gtk_main_quit ();
+      break;
+  }
+}  /* end p_fg_from_selectiont_response */
+
+
+ 
+
+/* ------------------------------
+ * do_dialog
+ * ------------------------------
+ * create and show the dialog window
+ */
+static void
+do_dialog (FgSelectDialogGuiStuff *guiStuffPtr, GapFgSelectValues *cuvals)
+{
+  GtkWidget  *vbox;
+
+  GtkWidget *dialog1;
+  GtkWidget *dialog_vbox1;
+  GtkWidget *frame1;
+  GtkWidget *vbox1;
+  GtkWidget *label;
+  GtkWidget *table1;
+  GtkObject *spinbutton_adj;
+  GtkWidget *spinbutton;
+  GtkWidget *dialog_action_area1;
+  GtkWidget *checkbutton;
+  GtkWidget *combo;
+  gint       row;
+
+
+  /* Init UI  */
+  gimp_ui_init ("Forground Extract", FALSE);
+
+
+  /*  The dialog1  */
+  guiStuffPtr->run = FALSE;
+  guiStuffPtr->vals = cuvals;
+
+
+  /*  The dialog1 and main vbox  */
+  dialog1 = gimp_dialog_new (_("Foreground-Extract"), "foreground_extract",
+                               NULL, 0,
+                               gimp_standard_help_func, PLUG_IN2_HELP_ID,
+                               
+                               GIMP_STOCK_RESET, GAP_FOREGROUND_FROM_SELECTION_RESPONSE_RESET,
+                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                               GTK_STOCK_OK,     GTK_RESPONSE_OK,
+                               NULL);
+
+  guiStuffPtr->shell = dialog1;
+
+
+  /*
+   * g_object_set_data (G_OBJECT (dialog1), "dialog1", dialog1);
+   * gtk_window_set_title (GTK_WINDOW (dialog1), _("dialog1"));
+   */
+
+
+  g_signal_connect (G_OBJECT (dialog1), "response",
+                      G_CALLBACK (p_fg_from_selectiont_response),
+                      guiStuffPtr);
+
+  /* the vbox */
+  vbox = gtk_vbox_new (FALSE, 2);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog1)->vbox), vbox,
+                      TRUE, TRUE, 0);
+  gtk_widget_show (vbox);
+
+  dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+  g_object_set_data (G_OBJECT (dialog1), "dialog_vbox1", dialog_vbox1);
+  gtk_widget_show (dialog_vbox1);
+
+
+
+  /* the frame */
+  frame1 = gimp_frame_new (_("Options"));
+
+  gtk_widget_show (frame1);
+  gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame1, TRUE, TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (frame1), 2);
+
+  vbox1 = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (frame1), vbox1);
+  gtk_widget_show (vbox1);
+
+
+  /* table1 for ...  */
+  table1 = gtk_table_new (4, 2, FALSE);
+  gtk_widget_show (table1);
+  gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (table1), 4);
+
+
+  row = 0;
+
+  /* the InnerRadius spinbutton  */
+  label = gtk_label_new (_("Inner Radius"));
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+  spinbutton_adj = gtk_adjustment_new (cuvals->innerRadius, 0.0, 500, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 2);
+  gimp_help_set_help_data (spinbutton, _("Radius for undefined (e.g. trimmable) area inside the selection border"), NULL);
+  gtk_widget_show (spinbutton);
+  gtk_table_attach (GTK_TABLE (table1), spinbutton, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  g_signal_connect (G_OBJECT (spinbutton_adj), "value_changed", G_CALLBACK (gimp_int_adjustment_update),
+                    &cuvals->innerRadius);
+  guiStuffPtr->colordiff_innerRadius_spinbutton_adj = spinbutton_adj;
+  guiStuffPtr->colordiff_innerRadius_spinbutton = spinbutton;
+
+  row++;
+
+  /* the OuterRadius spinbutton  */
+  label = gtk_label_new (_("Outer Radius"));
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+  spinbutton_adj = gtk_adjustment_new (cuvals->outerRadius, 0.0, 500, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 2);
+  gimp_help_set_help_data (spinbutton, _("Radius for undefined (e.g. trimmable) area outside the selection border"), NULL);
+  gtk_widget_show (spinbutton);
+  gtk_table_attach (GTK_TABLE (table1), spinbutton, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  g_signal_connect (G_OBJECT (spinbutton_adj), "value_changed", G_CALLBACK (gimp_int_adjustment_update),
+                    &cuvals->outerRadius);
+  guiStuffPtr->colordiff_outerRadius_spinbutton_adj = spinbutton_adj;
+  guiStuffPtr->colordiff_outerRadius_spinbutton = spinbutton;
+
+ 
+
+
+
+  row++;
+
+  /* create_layermask checkbutton  */
+  label = gtk_label_new (_("Create Layermask:"));
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+
+  checkbutton = gtk_check_button_new_with_label (" ");
+  g_object_set_data (G_OBJECT (checkbutton), "guiStuffPtr", guiStuffPtr);
+  guiStuffPtr->create_layermaskCheckbutton = checkbutton;
+  gimp_help_set_help_data (checkbutton, _("ON: render opacity by creating a new layer mask, "
+                                          "OFF: apply rendered opacity to the alpha channel"), NULL);
+  gtk_widget_show (checkbutton);
+  gtk_table_attach( GTK_TABLE(table1), checkbutton, 1, 2, row, row+1,
+                    GTK_FILL, 0, 0, 0 );
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), cuvals->create_layermask);
+  g_signal_connect (checkbutton, "toggled",
+                    G_CALLBACK (on_gboolean_button_update),
+                    &cuvals->create_layermask);
+
+  row++;
+
+
+  /* lock_color checkbutton  */
+  label = gtk_label_new (_("Lock Colors:"));
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+  checkbutton = gtk_check_button_new_with_label (" ");
+  g_object_set_data (G_OBJECT (checkbutton), "guiStuffPtr", guiStuffPtr);
+  guiStuffPtr->lock_colorCheckbutton = checkbutton;
+  gimp_help_set_help_data (checkbutton, _("ON: Keep RGB channels of the input layer, "
+                                          "OFF: allow Background color removal in processed undefined regions"), NULL);
+  gtk_widget_show (checkbutton);
+  gtk_table_attach( GTK_TABLE(table1), checkbutton, 1, 2, row, row+1,
+                    GTK_FILL, 0, 0, 0 );
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), cuvals->lock_color);
+  g_signal_connect (checkbutton, "toggled",
+                    G_CALLBACK (on_gboolean_button_update),
+                    &cuvals->lock_color);
+
+  row++;
+
+ 
+  /* colordiff_threshold spinbutton  */
+  label = gtk_label_new (_("Color Diff Threshold"));
+  //gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+  spinbutton_adj = gtk_adjustment_new (cuvals->colordiff_threshold, 0.0, 100, 0.1, 1, 0);
+  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 2);
+  gimp_help_set_help_data (spinbutton, _("sensitivity for color comparison"), NULL);
+  //gtk_widget_show (spinbutton);
+  gtk_table_attach (GTK_TABLE (table1), spinbutton, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  g_signal_connect (G_OBJECT (spinbutton_adj), "value_changed", G_CALLBACK (gimp_double_adjustment_update),
+                    &cuvals->colordiff_threshold);
+  guiStuffPtr->colordiff_threshold_spinbutton_adj = spinbutton_adj;
+  guiStuffPtr->colordiff_threshold_spinbutton = spinbutton;
+
+
+
+
+
+
+  /* -- */
+
+
+  dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
+  gtk_widget_show (dialog_action_area1);
+  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10);
+
+  p_init_widget_values(guiStuffPtr);
+  p_update_widget_sensitivity (guiStuffPtr);
+
+  gtk_widget_show (dialog1);
+
+  gtk_main ();
+  gdk_flush ();
+
+
+}  /* end do_dialog */
+
+
+
+void
+gap_fg_from_sel_init_default_vals(GapFgSelectValues *fsVals)
+{
+  fsVals->innerRadius = 7;
+  fsVals->outerRadius = 7;
+  fsVals->create_layermask = FALSE;
+  fsVals->lock_color = FALSE;
+  fsVals->colordiff_threshold = 1.0;
+}
+
+
+gboolean
+gap_fg_from_sel_dialog(GapFgSelectValues *fsVals)
+{
+  FgSelectDialogGuiStuff  guiStuff;
+  FgSelectDialogGuiStuff *guiStuffPtr;
+  
+  guiStuffPtr = &guiStuff;
+  guiStuffPtr->run = FALSE;
+  guiStuffPtr->drawable_id = fsVals->input_drawable_id;
+ 
+  /* Get information from the dialog */
+  do_dialog(guiStuffPtr, fsVals);
+  
+  return (guiStuffPtr->run);
+
+}  /* end gap_fg_from_sel_init_default_vals */
diff --git a/gap/gap_fg_from_sel_dialog.h b/gap/gap_fg_from_sel_dialog.h
new file mode 100644
index 0000000..9087ae8
--- /dev/null
+++ b/gap/gap_fg_from_sel_dialog.h
@@ -0,0 +1,41 @@
+/* gap_fg_from_sel_dialog.h
+ * 2011.11.15 hof (Wolfgang Hofer)
+ *
+ * GAP ... Gimp Animation Plugins
+ *
+ * This Module contains:
+ * - stuff for the GUI dialog
+ *   of the foreground extraction from current selection via alpha matting plug-in.
+ *
+ */
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GAP_FG_FROM_SEL_H
+#define GAP_FG_FROM_SEL_H
+
+#include "libgimp/gimp.h"
+
+/*
+ * DIALOG and callback stuff
+ */
+gboolean  gap_fg_from_sel_dialog(GapFgSelectValues *fsVals);
+void      gap_fg_from_sel_init_default_vals(GapFgSelectValues *fsVals);
+
+
+#endif /* GAP_FG_FROM_SEL_H */
diff --git a/gap/gap_fg_matting_exec.c b/gap/gap_fg_matting_exec.c
index e3c2890..514ca48 100644
--- a/gap/gap_fg_matting_exec.c
+++ b/gap/gap_fg_matting_exec.c
@@ -53,10 +53,6 @@
 static gboolean globalDoProgress;
 
 
-static GimpDrawable *globalDrawable = NULL;
-
-
-
 static gint32 gap_drawable_foreground_extract (GimpDrawable              *drawable,
                                  GimpDrawable              *maskDrawable,
                                  GapFgExtractValues        *fgValPtr
@@ -569,4 +565,145 @@ gap_drawable_foreground_extract_matting_done (GappMattingState *state)
 
 
 
+/* --------------------------------------------
+ * gap_fg_from_selection_exec_apply_run
+ * --------------------------------------------
+ * generate a tri map from the current selection by filling the shrinked
+ * shape with white, the expanded shape with black and the borderline
+ * between shrinked and expanded selection with medium gray.
+ * the trimap is attached as layermask to the input drawable,
+ * and used as input for the foreground selection via alpha matting algorithm,
+ * that creates a resulting layer with trimmed selection.
+ *
+ */
+gint
+gap_fg_from_selection_exec_apply_run (gint32 image_id, gint32 drawable_id
+                             , gboolean doProgress, gboolean doFlush
+                             , GapFgSelectValues *fsValPtr)
+{
+  GimpRGB   color;
+  gint32    activeSelection;
+  gint32    shrinkedSelection;
+  gint32    trimap;
+  gboolean  hadSelection;
+  gint      rc;
+
+  rc = 0;
+  trimap = -1;
+  activeSelection = -1;
+  shrinkedSelection = -1;
+  hadSelection = FALSE;
+  
+  gimp_context_push();
+  gimp_image_undo_group_start(image_id);
+  
+
+  if (gimp_selection_is_empty(image_id) == TRUE)
+  {
+     if (gimp_drawable_has_alpha(drawable_id) == FALSE)
+     {
+       /* if the layer has no alpha select all */
+       gimp_selection_all(image_id);
+     }
+     else
+     {
+       gimp_selection_layer_alpha(drawable_id);
+     }
+     activeSelection = gimp_selection_save(image_id);
+  }
+  else
+  {
+    activeSelection = gimp_selection_save(image_id);
+    hadSelection = TRUE;
+  }
+
+
+  trimap = gimp_layer_get_mask(drawable_id);
+  if (trimap < 0)
+  {
+    /* create trimap as new layermask */
+    trimap = gimp_layer_create_mask(drawable_id, GIMP_ADD_BLACK_MASK);
+    gimp_layer_add_mask(drawable_id, trimap);
+  }
+  else
+  {
+    /* use BLACK color to fill the already existing layermask
+     * (note that gimp_drawable_fill is used to fill the entire mask
+     * regardless to the current selection)
+     */
+    color.r = 0.0;
+    color.g = 0.0;
+    color.b = 0.0;
+    color.a = 1.0;
+    gimp_context_set_background (&color);
+    gimp_drawable_fill(trimap, GIMP_BACKGROUND_FILL);
+  }
+  
+  gimp_selection_sharpen(image_id);
+  if (fsValPtr->innerRadius > 0)
+  {
+    gimp_selection_shrink(image_id, fsValPtr->innerRadius);
+  }
+  shrinkedSelection = gimp_selection_save(image_id);
+  
+  
+  /* use WHITE color to mark foreground regions
+   */
+  color.r = 1.0;
+  color.g = 1.0;
+  color.b = 1.0;
+  color.a = 1.0;
+  gimp_context_set_background (&color);
+  gimp_edit_fill(trimap, GIMP_BACKGROUND_FILL);
+  
+  gimp_selection_load(activeSelection);
+  gimp_selection_sharpen(image_id);
+  if (fsValPtr->outerRadius > 0)
+  {
+    gimp_selection_grow(image_id, fsValPtr->outerRadius);
+  }
+  gimp_selection_combine(shrinkedSelection, GIMP_CHANNEL_OP_SUBTRACT);
+
+  /* use medium GRAY to mark undefined regions
+   */
+  color.r = 0.5;
+  color.g = 0.5;
+  color.b = 0.5;
+  color.a = 1.0;
+  gimp_context_set_background (&color);
+  gimp_edit_fill(trimap, GIMP_BACKGROUND_FILL);
+
+  gimp_selection_none(image_id);
+
+  /* perform the foreground selection (that creates the resulting layer) */
+  {
+    GapFgExtractValues fgExtractValues;
+    GapFgExtractValues *fgValPtr;
+    
+    fgValPtr = &fgExtractValues;
+    fgValPtr->input_drawable_id = drawable_id;
+    fgValPtr->tri_map_drawable_id = trimap;
+    fgValPtr->create_result = TRUE;
+    fgValPtr->create_layermask = fsValPtr->create_layermask;
+    fgValPtr->lock_color = fsValPtr->lock_color;
+    fgValPtr->colordiff_threshold = fsValPtr->colordiff_threshold;
+
+    rc = gap_fg_matting_exec_apply_run (image_id, drawable_id
+                                 , doProgress, doFlush
+                                 , fgValPtr
+                                 );
+  }
+  
+  
+  /* restore original selection */
+  if (hadSelection == TRUE)
+  {
+    gimp_selection_load(activeSelection);
+  }
+
+  gimp_image_undo_group_end(image_id);
+  gimp_context_pop();
+  
+  return (rc);
 
+}  /* end gap_fg_from_selection_exec_apply_run */
diff --git a/gap/gap_fg_matting_exec.h b/gap/gap_fg_matting_exec.h
index 0e715c9..e4f0768 100644
--- a/gap/gap_fg_matting_exec.h
+++ b/gap/gap_fg_matting_exec.h
@@ -43,4 +43,9 @@ gap_fg_matting_exec_apply_run (gint32 image_id, gint32 drawable_id
                              , gboolean doProgress, gboolean doFlush
                              , GapFgExtractValues *fgValPtr);
 
+gint
+gap_fg_from_selection_exec_apply_run (gint32 image_id, gint32 drawable_id
+                             , gboolean doProgress, gboolean doFlush
+                             , GapFgSelectValues *fsValPtr);
+
 #endif /* GAP_FG_MATTING_EXEC_H */
diff --git a/gap/gap_fg_matting_main.c b/gap/gap_fg_matting_main.c
index f9ef6ec..396b2ad 100644
--- a/gap/gap_fg_matting_main.c
+++ b/gap/gap_fg_matting_main.c
@@ -2,10 +2,17 @@
  *    foreground extraction based on alpha matting algorithm.
  *    Render transparancy for a layer based on a tri-map drawable (provided by the user).
  *    The tri-map defines what pixels are FOREGROUND (white) BACKGROUND (black) or UNDEFINED (gray).
- *    foreground extraction affects the UNDEFINED pixels and calculates transparency for those pixels.
+ *    foreground extraction affects the UNDEFINED pixels and calculates transparency 
+ *    (and optionally color) for those pixels.
  *
- *    This module handles PDB registration as GIMP plug-in
- *  2011/10/05
+ *    This module handles PDB registration as GIMP plug-ins
+ *    Implemented Plug-in variants:
+ *     a) The user provides the tri map as layermask or as independent layer
+ *     b) tri map is generated from the current selection where the user
+ *        specifies the width of undefined range inside and outside the selection borderline.
+ *        Alpha matting is used to trim the undefined borderline.
+ *     
+ *  2011/11/15
  */
 /* The GIMP -- an image manipulation program
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
@@ -46,6 +53,7 @@ int gap_debug = 1;  /* 1 == print debug infos , 0 dont print debug infos */
 #include "gap_fg_matting_exec.h"
 #include "gap_fg_tile_manager.h"
 #include "gap_fg_matting_dialog.h"
+#include "gap_fg_from_sel_dialog.h"
 #include "gap_fg_matting.h"
 #include "gap_fg_regions.h"
 
@@ -57,11 +65,22 @@ static GapFgExtractValues fgVals =
  , -1        /* tri_map_drawable_id */
  , FALSE     /* create_layermask   */
  , TRUE      /* lock_color */
-// , TRUE     /* create_result */
-// , 1.0       /* colordiff_threshold */
+ , TRUE      /* create_result */
+ , 1.0       /* colordiff_threshold */
 };
 
 
+static GapFgSelectValues fsVals =
+{
+   -1        /* input_drawable_id */
+ , -1        /* tri_map_drawable_id */
+ , 7         /* innerRadius */
+ , 7         /* outerRadius */
+ , FALSE     /* create_layermask   */
+ , TRUE      /* lock_color */
+ , 1.0       /* colordiff_threshold */
+};
+
 
 
 static void  query (void);
@@ -72,25 +91,6 @@ static void  run (const gchar *name,          /* name of plugin */
      GimpParam ** return_vals);  /* out-parameters */
 
 
-static gint32 gap_drawable_foreground_extract (GimpDrawable              *drawable,
-                                 GimpDrawable              *maskDrawable,
-                                 GapFgExtractValues        *fgValPtr
-                                 );
-static GappMattingState * gap_drawable_foreground_extract_matting_init (GimpDrawable *drawable,
-                                               gint          mask_x,
-                                               gint          mask_y,
-                                               gint          mask_width,
-                                               gint          mask_height);
-static void  gap_drawable_foreground_extract_matting (GimpDrawable       *maskDrawable,
-                                         GimpDrawable       *resultDrawable,
-                                         GappMattingState   *state,
-                                         gfloat              start_percentage
-                                         );
-static void  gap_drawable_foreground_extract_matting_done (GappMattingState *state);
-
-static gint32  p_tri_map_preprocessing (GimpDrawable *drawable, GapFgExtractValues *fgValPtr, gint32 *dummyLayerId);
-
-
 
 /* Global Variables */
 GimpPlugInInfo PLUG_IN_INFO =
@@ -110,13 +110,13 @@ static const GimpParamDef in_args[] =
                                              "konwn forground (>= 240), known background (0) and unkonwn (128) values"
                                              "This drawable must have same size as the Input-Layer "
                                              "specify -1 to use the layer-mask of the input drawable as tri-map."},
-    { GIMP_PDB_INT32,    "create-result",    "0 .. overwrite the input layer with the processing result. "
-                                             "1 .. return the result as new layer (and add the resulting layer above the input layer)" },
     { GIMP_PDB_INT32,    "create-layermask", "0 .. render transparency as alpha channel. "
                                              "1 .. render transparency as layer mask." },
     { GIMP_PDB_INT32,    "lock-color",       "0 .. remove background color in semi transparent pixels. "
-                                             "1 .. keep original colors for all pixels (affect only transparency)." },
-    { GIMP_PDB_FLOAT,    "colordiff-threshold", "colordiff threshold in range #.# to #.#." }
+                                             "1 .. keep original colors for all pixels (affect only transparency)." }
+//    { GIMP_PDB_INT32,    "create-result",    "0 .. overwrite the input layer with the processing result. "
+//                                             "1 .. return the result as new layer (and add the resulting layer above the input layer)" },
+//    { GIMP_PDB_FLOAT,    "colordiff-threshold", "colordiff threshold in range #.# to #.#." }
 };
 
 
@@ -128,6 +128,24 @@ static gint global_number_in_args = G_N_ELEMENTS (in_args);
 static gint global_number_out_args = G_N_ELEMENTS (return_vals);
 
 
+static const GimpParamDef in2_args[] =
+{
+    { GIMP_PDB_INT32,    "run-mode",      "Interactive, non-interactive" },
+    { GIMP_PDB_IMAGE,    "image",         "Input image"                  },
+    { GIMP_PDB_DRAWABLE, "drawable",      "Input layer (RGB or RGBA)"               },
+    { GIMP_PDB_INT32,    "inner-radius",  "Radius for undefined (e.g. trimmable) area inside the selection border in pixels" },
+    { GIMP_PDB_INT32,    "outer-radius",  "Radius for undefined (e.g. trimmable) area outside the selection border in pixels" },
+    { GIMP_PDB_INT32,    "create-layermask", "0 .. render transparency as alpha channel. "
+                                             "1 .. render transparency as layer mask." },
+    { GIMP_PDB_INT32,    "lock-color",       "0 .. remove background color in semi transparent pixels. "
+                                             "1 .. keep original colors for all pixels (affect only transparency)." }
+//    { GIMP_PDB_FLOAT,    "colordiff-threshold", "colordiff threshold in range #.# to #.#." }
+};
+
+static gint global_number_in2_args = G_N_ELEMENTS (in2_args);
+
+
+
 /* Functions */
 
 MAIN ()
@@ -145,11 +163,11 @@ static void query (void)
                           "according to the supplied tri-mask, where the tri mask defines the opacity in the corresponding "
                           "pixel in the resulting layer. "
                           "White pixels (>= 240) in the tri-mask will set corresponding result pixels to fully opaque, "
-                          "Black pixels (0) in the tri-mask will set corresponding result pixels to fully tranparent, "
-                          "Gray pixels in the tri-mask mark UNDEFINED areas and will trigger cthe calculation of transparency (and optionally color) "
+                          "Black pixels (0) in the tri-mask will set corresponding result pixels to fully transparent, "
+                          "Gray pixels in the tri-mask mark UNDEFINED areas and will trigger the calculation of transparency (and optionally color) "
                           "of the corresponding result pixel, depending on its color compared with near foreground and backround pixels. "
-                          "the result is written to a newly created layer or optionally overwrites the input layer. "
-                          "in case where the input layer has already an alpha channel fully transparent pixels in the input layer"
+                          "the result is written to a newly created layer. "
+                          "in case where the input layer has already an alpha channel, fully transparent pixels in the input layer"
                           "are not affected "
                           "(e.g. keep their full transparency, even if the tri-map marks this pixels as foreground) "
                           " ",
@@ -164,17 +182,38 @@ static void query (void)
                           in_args,
                           return_vals);
 
+  gimp_install_procedure (PLUG_IN2_NAME,
+                          "Duplicate selected foreground to a new layer based on trimmed selection via alpha matting.",
+                          "This plug-in generates a tri map based on the current selection and "
+                          "attaches the generated tri map as layermask to the Input layer, "
+                          "A new resulting layer is created as copy of the selected foreground object of the input layer, "
+                          "where the generated tri map is used to trim the selection via the alpha matting algorithm. "
+                          "White pixels (>= 240) in the tri-mask will set corresponding result pixels to fully opaque, "
+                          "Black pixels (0) in the tri-mask will set corresponding result pixels to fully transparent, "
+                          "Gray pixels in the tri-mask mark UNDEFINED areas and will trigger the calculation of transparency (and optionally color) "
+                          "of the corresponding result pixel, depending on its color compared with near foreground and backround pixels. "
+                          "the result is written to a newly created layer. "
+                          "in case where the input layer already has a layer mask it is replaced with the newly generated one. "
+                          "are not affected "
+                          "(e.g. keep their full transparency, even if the tri-map marks this pixels as foreground) "
+                          " ",
+                          PLUG_IN2_AUTHOR,
+                          PLUG_IN2_COPYRIGHT,
+                          GAP_VERSION_WITH_DATE,
+                          N_("Foreground Extract Via Selection..."),
+                          PLUG_IN2_IMAGE_TYPES,
+                          GIMP_PLUGIN,
+                          global_number_in2_args,
+                          global_number_out_args,
+                          in2_args,
+                          return_vals);
+
   {
     /* Menu names */
-    const char *menupath_image_video_layer_attr = N_("<Image>/Video/Layer/Attributes/");
     const char *menupath_image_layer_tranparency = N_("<Image>/Layer/Transparency/");
 
-
-    //gimp_plugin_menu_branch_register("<Image>", "Video");
-    //gimp_plugin_menu_branch_register("<Image>/Video", "Layer");
-
-    gimp_plugin_menu_register (PLUG_IN_NAME, menupath_image_video_layer_attr);
     gimp_plugin_menu_register (PLUG_IN_NAME, menupath_image_layer_tranparency);
+    gimp_plugin_menu_register (PLUG_IN2_NAME, menupath_image_layer_tranparency);
   }
 
 }  /* end query */
@@ -228,6 +267,7 @@ run (const gchar *name,          /* name of plugin */
   *return_vals = values;
 
   gap_fg_matting_init_default_vals(&fgVals);
+  gap_fg_from_sel_init_default_vals(&fsVals);
 
   /* get image and drawable */
   image_id = param[1].data.d_int32;
@@ -235,14 +275,28 @@ run (const gchar *name,          /* name of plugin */
 
   /* Possibly retrieve data from a previous run */
   gimp_get_data (name, &fgVals);
+  gimp_get_data (name, &fsVals);
   fgVals.input_drawable_id = activeDrawableId;
+  fsVals.input_drawable_id = activeDrawableId;
 
   /* how are we running today? */
   switch (run_mode)
   {
+    gboolean dialogOk;
+    
+    dialogOk = FALSE;
+    
     case GIMP_RUN_INTERACTIVE:
       /* Get information from the dialog */
-      if (!gap_fg_matting_dialog(&fgVals))
+      if (strcmp(name, PLUG_IN2_NAME) == 0)
+      {
+        dialogOk = gap_fg_from_sel_dialog(&fsVals);
+      }
+      else
+      {
+        dialogOk = gap_fg_matting_dialog(&fgVals);
+      }
+      if (!dialogOk)
       {
         /* return without processing in case the Dialog was cancelled */
         return;
@@ -252,18 +306,37 @@ run (const gchar *name,          /* name of plugin */
 
     case GIMP_RUN_NONINTERACTIVE:
       /* check to see if invoked with the correct number of parameters */
-      if (nparams == global_number_in_args)
+      if (strcmp(name, PLUG_IN2_NAME) == 0)
       {
-          fgVals.input_drawable_id = activeDrawableId;
-          fgVals.tri_map_drawable_id  = (gint32)  param[3].data.d_drawable;
-          fgVals.create_layermask     = (param[4].data.d_int32 == 0) ? FALSE : TRUE;
-          fgVals.lock_color           = (param[5].data.d_int32 == 0) ? FALSE : TRUE;
-//          fgVals.create_result        = (param[6].data.d_int32 == 0) ? FALSE : TRUE;
-//          fgVals.colordiff_threshold  = (gdouble) param[7].data.d_float;
+        if (nparams == global_number_in2_args)
+        {
+            fsVals.input_drawable_id = activeDrawableId;
+            fsVals.innerRadius  = (gint32)  param[3].data.d_int32;
+            fsVals.outerRadius  = (gint32)  param[4].data.d_int32;
+            fsVals.create_layermask     = (param[5].data.d_int32 == 0) ? FALSE : TRUE;
+            fsVals.lock_color           = (param[6].data.d_int32 == 0) ? FALSE : TRUE;
+//            fsVals.colordiff_threshold  = (gdouble) param[7].data.d_float;
+        }
+        else
+        {
+          status = GIMP_PDB_CALLING_ERROR;
+        }
       }
       else
       {
-        status = GIMP_PDB_CALLING_ERROR;
+        if (nparams == global_number_in_args)
+        {
+            fgVals.input_drawable_id = activeDrawableId;
+            fgVals.tri_map_drawable_id  = (gint32)  param[3].data.d_drawable;
+            fgVals.create_layermask     = (param[4].data.d_int32 == 0) ? FALSE : TRUE;
+            fgVals.lock_color           = (param[5].data.d_int32 == 0) ? FALSE : TRUE;
+//            fgVals.create_result        = (param[6].data.d_int32 == 0) ? FALSE : TRUE;
+//            fgVals.colordiff_threshold  = (gdouble) param[7].data.d_float;
+        }
+        else
+        {
+          status = GIMP_PDB_CALLING_ERROR;
+        }
       }
 
       break;
@@ -277,14 +350,34 @@ run (const gchar *name,          /* name of plugin */
 
   if (status == GIMP_PDB_SUCCESS)
   {
-	gboolean doFlush;
-
-	doFlush =  (run_mode == GIMP_RUN_INTERACTIVE);
-    fgVals.input_drawable_id    = (gint32)  param[2].data.d_drawable;
+    gboolean doFlush;
 
+    doFlush =  (run_mode == GIMP_RUN_INTERACTIVE);
+   
     /* Run the main function */
-    values[1].data.d_drawable =
-        gap_fg_matting_exec_apply_run(image_id, param[2].data.d_drawable, doProgress, doFlush, &fgVals);
+    if (strcmp(name, PLUG_IN2_NAME) == 0)
+    {
+      values[1].data.d_drawable =
+          gap_fg_from_selection_exec_apply_run(image_id, activeDrawableId, doProgress, doFlush, &fsVals);
+
+      /* Store variable states for next run */
+      if (run_mode == GIMP_RUN_INTERACTIVE)
+      {
+        gimp_set_data (name, &fsVals, sizeof (GapFgSelectValues));
+      }
+    }
+    else
+    {
+      values[1].data.d_drawable =
+          gap_fg_matting_exec_apply_run(image_id, activeDrawableId, doProgress, doFlush, &fgVals);
+
+      /* Store variable states for next run */
+      if (run_mode == GIMP_RUN_INTERACTIVE)
+      {
+        gimp_set_data (name, &fgVals, sizeof (GapFgExtractValues));
+      }
+    }
+    
     if (values[1].data.d_drawable < 0)
     {
        status = GIMP_PDB_CALLING_ERROR;
@@ -298,15 +391,9 @@ run (const gchar *name,          /* name of plugin */
       gimp_displays_flush ();
     }
 
-    /* Store variable states for next run */
-    if (run_mode == GIMP_RUN_INTERACTIVE)
-    {
-      gimp_set_data (name, &fgVals, sizeof (GapFgExtractValues));
-    }
 
   }
   values[0].data.d_status = status;
 
-
 }       /* end run */
 
diff --git a/gap/gap_fg_matting_main.h b/gap/gap_fg_matting_main.h
index 1e9f2b9..2a3fb9e 100644
--- a/gap/gap_fg_matting_main.h
+++ b/gap/gap_fg_matting_main.h
@@ -44,10 +44,16 @@
 #define PLUG_IN_COPYRIGHT   "Jan Ruegg / Wolfgang Hofer"
 #define PLUG_IN_HELP_ID     "plug-in-foreground-extract-matting"
 
+#define PLUG_IN2_NAME        "plug-in-selection-to-foreground-layer"
+#define PLUG_IN2_PRINT_NAME  "Selection To Foreground Extract"
+#define PLUG_IN2_IMAGE_TYPES "RGB*"
+#define PLUG_IN2_AUTHOR      "Wolfgang Hofer (hof gimp org)"
+#define PLUG_IN2_COPYRIGHT   "Wolfgang Hofer"
+#define PLUG_IN2_HELP_ID     "plug-in-selection-to-foreground-layer"
 
 
 
-typedef struct GapFgExtractValues {
+typedef struct GapFgExtractValues {  /* fgValPtr */
   gint32 input_drawable_id;
   gint32 tri_map_drawable_id;
   gboolean create_result;
@@ -58,4 +64,17 @@ typedef struct GapFgExtractValues {
 } GapFgExtractValues;
 
 
+
+typedef struct GapFgSelectValues {  /* fsValPtr */
+  gint32 input_drawable_id;
+  gint32 tri_map_drawable_id;
+  gint     innerRadius;
+  gint     outerRadius;
+  gboolean create_layermask;
+  gboolean lock_color;
+  gdouble  colordiff_threshold;
+
+} GapFgSelectValues;
+
+
 #endif /* GAP_FG_MATTING_MAIN_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a4d178f..1fb3db7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,6 +21,7 @@ gap/gap_fg_matting_main.c
 gap/gap_fg_matting_exec.c
 gap/gap_fg_matting.c
 gap/gap_fg_matting_dialog.c
+gap/gap_fg_from_sel_dialog.c
 gap/gap_fg_regions.c
 gap/gap_fmac_base.c
 gap/gap_fmac_main.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]