diff --git a/src/trace/siox.h b/src/trace/siox.h
index 5d36a71f660e13540fdbe80fc84ca506d58f0266..6b7256fe0f37a7b2b6bfd587e3c6a253797a1362 100644 (file)
--- a/src/trace/siox.h
+++ b/src/trace/siox.h
-#ifndef __SIOX_SEGMENTATOR_H__
-#define __SIOX_SEGMENTATOR_H__
-/*
- Copyright 2005, 2006 by Gerald Friedland, Kristian Jantz and Lars Knipping
+#ifndef __SIOX_H__
+#define __SIOX_H__
+/**
+ * Copyright 2005, 2006 by Gerald Friedland, Kristian Jantz and Lars Knipping
+ *
+ * Conversion to C++ for Inkscape by Bob Jamison
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
- Conversion to C++ for Inkscape by Bob Jamison
+/**
+ * Note by Bob Jamison:
+ * After translating the siox.org Java API to C++ and receiving an
+ * education into this wonderful code, I began again,
+ * and started this version using lessons learned. This version is
+ * an attempt to provide an dependency-free SIOX engine that anyone
+ * can use in their project with minimal effort.
+ *
+ * Many thanks to the fine people at siox.org.
+ */
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+#include <string>
+#include <vector>
- http://www.apache.org/licenses/LICENSE-2.0
+#define HAVE_GLIB
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
+#ifdef HAVE_GLIB
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#endif
-#include <map>
-#include <vector>
namespace org
{
+
namespace siox
{
-/**
- * Image segmentator based on
- *<em>SIOX: Simple Interactive Object Extraction</em>.
- * <P>
- * To segmentate an image one has to perform the following steps.
- * <OL><LI>Construct an instance of <code>SioxSegmentator</code>.
- * </LI><LI>Create a confidence matrix, where each entry marks its
- * corresponding image pixel to belong to the foreground, to the
- * background, or being of unknown type.
- * </LI><LI>Call <code>segmentate</code> on the image with the confidence
- * matrix. This stores the result as new foreground confidence into
- * the confidence matrix, with each entry being either
- * zero (<code>CERTAIN_BACKGROUND_CONFIDENCE</code>) or one
- * (<code>CERTAIN_FOREGROUND_CONFIDENCE</code>).
- * </LI><LI>Optionally call <code>subpixelRefine</code> to areas
- * where pixels contain both foreground and background (e.g.
- * object borders or highly detailed features like flowing hairs).
- * The pixel are then assigned confidence values bwetween zero and
- * one to give them a measure of "foregroundness".
- * This step may be repeated as often as needed.
- * </LI></OL>
- * <P>
- * For algorithm documentation refer to
- * G. Friedland, K. Jantz, L. Knipping, R. Rojas:<i>
- * Image Segmentation by Uniform Color Clustering
- * -- Approach and Benchmark Results</i>,
- * <A HREF="http://www.inf.fu-berlin.de/inst/pubs/tr-b-05-07.pdf">Technical Report B-05-07</A>,
- * Department of Computer Science, Freie Universitaet Berlin, June 2005.<br>
- * <P>
- * See <A HREF="http://www.siox.org/" target="_new">http://www.siox.org</A> for more information.<br>
- * <P>
- * Algorithm idea by Gerald Friedland.
- *
- * @author Gerald Friedland, Kristian Jantz, Lars Knipping
- * @version 1.12
- */
+
+//########################################################################
+//# C L A B
+//########################################################################
/**
- * Helper class for storing the minimum distances to a cluster centroid
- * in background and foreground and the index to the centroids in each
- * signature for a given color.
+ *
*/
-class Tupel {
+class CieLab
+{
public:
- Tupel()
- {
- minBgDist = 0.0f;
- indexMinBg = 0;
- minFgDist = 0.0f;
- indexMinFg = 0;
- }
- Tupel(float minBgDistArg, long indexMinBgArg,
- float minFgDistArg, long indexMinFgArg)
- {
- minBgDist = minBgDistArg;
- indexMinBg = indexMinBgArg;
- minFgDist = minFgDistArg;
- indexMinFg = indexMinFgArg;
- }
- Tupel(const Tupel &other)
- {
- minBgDist = other.minBgDist;
- indexMinBg = other.indexMinBg;
- minFgDist = other.minFgDist;
- indexMinFg = other.indexMinFg;
- }
- Tupel &operator=(const Tupel &other)
+ /**
+ *
+ */
+ CieLab()
{
- minBgDist = other.minBgDist;
- indexMinBg = other.indexMinBg;
- minFgDist = other.minFgDist;
- indexMinFg = other.indexMinFg;
- return *this;
+ init();
+ C = 0;
+ L = A = B = 0.0f;
}
- virtual ~Tupel()
- {}
- float minBgDist;
- long indexMinBg;
- float minFgDist;
- long indexMinFg;
- };
+ /**
+ *
+ */
+ CieLab(unsigned long rgb);
-class CLAB
-{
-public:
- CLAB()
- {
- C = L = A = B = 0.0f;
- }
- CLAB(float lArg, float aArg, float bArg)
+ /**
+ *
+ */
+ CieLab(float lArg, float aArg, float bArg)
{
- C = 0.0f;
+ init();
+ C = 0;
L = lArg;
A = aArg;
B = bArg;
}
- CLAB(const CLAB &other)
+
+
+ /**
+ *
+ */
+ CieLab(const CieLab &other)
{
+ init();
C = other.C;
L = other.L;
A = other.A;
B = other.B;
}
- CLAB &operator=(const CLAB &other)
+
+
+ /**
+ *
+ */
+ CieLab &operator=(const CieLab &other)
{
+ init();
C = other.C;
L = other.L;
A = other.A;
B = other.B;
return *this;
}
- virtual ~CLAB()
+
+ /**
+ *
+ */
+ virtual ~CieLab()
{}
- float C;
+ /**
+ * Retrieve a CieLab value via index.
+ */
+ virtual float operator()(unsigned int index)
+ {
+ if (index==0) return L;
+ else if (index==1) return A;
+ else if (index==2) return B;
+ else return 0;
+ }
+
+
+ /**
+ *
+ */
+ virtual void add(const CieLab &other)
+ {
+ C += other.C;
+ L += other.L;
+ A += other.A;
+ B += other.B;
+ }
+
+
+ /**
+ *
+ */
+ virtual void mul(float scale)
+ {
+ L *= scale;
+ A *= scale;
+ B *= scale;
+ }
+
+
+ /**
+ *
+ */
+ virtual unsigned long toRGB();
+
+ /**
+ * Approximate cube roots
+ */
+ double cbrt(double x);
+
+ /**
+ *
+ */
+ double qnrt(double x);
+
+ /**
+ * Raise to the 2.4 power
+ */
+ double pow24(double x);
+
+ /**
+ * Squared Euclidian distance between this and another color
+ */
+ float diffSq(const CieLab &other);
+
+ /**
+ * Computes squared euclidian distance in CieLab space for two colors
+ * given as RGB values.
+ */
+ static float diffSq(unsigned int rgb1, unsigned int rgb2);
+
+ /**
+ * Computes squared euclidian distance in CieLab space for two colors
+ * given as RGB values.
+ */
+ static float diff(unsigned int rgb0, unsigned int rgb1);
+
+
+ unsigned int C;
float L;
float A;
float B;
+
+private:
+
+ /**
+ *
+ */
+ void init();
+
+
};
-class SioxSegmentator
+//########################################################################
+//# S I O X I M A G E
+//########################################################################
+
+/**
+ * This is a generic image type that provides a consistent interface
+ * to Siox, so that developers will not need to worry about data arrays.
+ */
+class SioxImage
{
public:
- /** Confidence corresponding to a certain foreground region (equals one). */
- static const float CERTAIN_FOREGROUND_CONFIDENCE; //=1.0f;
+ /**
+ * Create an image with the given width and height
+ */
+ SioxImage(unsigned int width, unsigned int height);
- /** Confidence for a region likely being foreground.*/
- static const float FOREGROUND_CONFIDENCE; //=0.8f;
+ /**
+ * Copy constructor
+ */
+ SioxImage(const SioxImage &other);
- /** Confidence for foreground or background type being equally likely.*/
- static const float UNKNOWN_REGION_CONFIDENCE; //=0.5f;
+ /**
+ * Assignment
+ */
+ SioxImage &operator=(const SioxImage &other);
- /** Confidence for a region likely being background.*/
- static const float BACKGROUND_CONFIDENCE; //=0.1f;
+ /**
+ * Clean up after use.
+ */
+ virtual ~SioxImage();
- /** Confidence corresponding to a certain background reagion (equals zero). */
- static const float CERTAIN_BACKGROUND_CONFIDENCE; //=0.0f;
+ /**
+ * Returns true if the previous operation on this image
+ * was successful, else false.
+ */
+ virtual bool isValid();
+ /**
+ * Sets whether an operation was successful, and whether
+ * this image should be considered a valid one.
+ * was successful, else false.
+ */
+ virtual void setValid(bool val);
/**
- * Constructs a SioxSegmentator Object to be used for image segmentation.
- *
- * @param w X resolution of the image to be segmentated.
- * @param h Y resolution of the image to be segmentated.
- * @param limits Size of the cluster on LAB axises.
- * If <code>null</code>, the default value {0.64f,1.28f,2.56f}
- * is used.
+ * Set a pixel at the x,y coordinates to the given value.
+ * If the coordinates are out of range, do nothing.
*/
- SioxSegmentator(int w, int h, float *limitsArg, int limitsSize);
+ virtual void setPixel(unsigned int x,
+ unsigned int y,
+ unsigned int pixval);
/**
- * Destructor
+ * Set a pixel at the x,y coordinates to the given r, g, b values.
+ * If the coordinates are out of range, do nothing.
*/
- virtual ~SioxSegmentator();
+ virtual void setPixel(unsigned int x, unsigned int y,
+ unsigned int a,
+ unsigned int r,
+ unsigned int g,
+ unsigned int b);
+
+ /**
+ * Get a pixel at the x,y coordinates given. If
+ * the coordinates are out of range, return 0
+ */
+ virtual unsigned int getPixel(unsigned int x, unsigned int y);
/**
- * Segmentates the given image with information from the confidence
- * matrix.
- * <P>
- * The confidence entries of <code>BACKGROUND_CONFIDENCE</code> or less
- * are mark known background pixel for the segmentation, those
- * of at least <code>FOREGROUND_CONFIDENCE</code> mark known
- * foreground pixel for the segmentation. Any other entry is treated
- * as region of unknown affiliation.
- * <P>
- * As result, each pixel is classified either as foregroound or
- * background, stored back into its <code>cm</code> entry as confidence
- * <code>CERTAIN_FOREGROUND_CONFIDENCE</code> or
- * <code>CERTAIN_BACKGROUND_CONFIDENCE</code>.
- *
- * @param image Pixel data of the image to be segmentated.
- * Every integer represents one ARGB-value.
- * @param cm Confidence matrix specifying the probability of an image
- * belonging to the foreground before and after the segmentation.
- * @param smoothness Number of smoothing steps in the post processing.
- * Both arrays should be width * height in size.
- * @param sizeFactorToKeep Segmentation retains the largest connected
- * foreground component plus any component with size at least
- * <CODE>sizeOfLargestComponent/sizeFactorToKeep</CODE>.
- * @return <CODE>true</CODE> if the segmentation algorithm succeeded,
- * <CODE>false</CODE> if segmentation is impossible
- */
- bool segmentate(unsigned long *image, float *cm,
- int smoothness, double sizeFactorToKeep);
-
- /**
- * Clears given confidence matrix except entries for the largest connected
- * component and every component with
- * <CODE>size*sizeFactorToKeep >= sizeOfLargestComponent</CODE>.
- *
- * @param cm Confidence matrix to be analysed
- * @param threshold Pixel visibility threshold.
- * Exactly those cm entries larger than threshold are considered
- * to be a "visible" foreground pixel.
- * @param sizeFactorToKeep This method keeps the largest connected
- * component plus any component with size at least
- * <CODE>sizeOfLargestComponent/sizeFactorToKeep</CODE>.
- */
- void keepOnlyLargeComponents(float *cm,
- float threshold,
- double sizeFactorToKeep);
+ * Return the image data buffer
+ */
+ virtual unsigned int *getImageData();
/**
- * Depth first search pixels in a foreground component.
- *
- * @param cm confidence matrix to be searched.
- * @param i starting position as index to confidence matrix.
- * @param threshold defines the minimum value at which a pixel is
- * considered foreground.
- * @param curlabel label no of component.
- * @return size in pixel of the component found.
- */
- int depthFirstSearch(float *cm, int i, float threshold, int curLabel);
-
- /**
- * Refines the classification stored in the confidence matrix by modifying
- * the confidences for regions which have characteristics to both
- * foreground and background if they fall into the specified square.
- * <P>
- * The can be used in displaying the image by assigning the alpha values
- * of the pixels according to the confidence entries.
- * <P>
- * In the algorithm descriptions and examples GUIs this step is referrered
- * to as <EM>Detail Refinement (Brush)</EM>.
- *
- * @param x Horizontal coordinate of the squares center.
- * @param y Vertical coordinate of the squares center.
- * @param brushmode Mode of the refinement applied, <CODE>ADD_EDGE</CODE>
- * or <CODE>SUB_EDGE</CODE>. Add mode only modifies pixels
- * formerly classified as background, sub mode only those
- * formerly classified as foreground.
- * @param threshold Threshold for the add and sub refinement, deciding
- * at the confidence level to stop at.
- * @param cf The confidence matrix to modify, generated by
- * <CODE>segmentate</CODE>, possibly already refined by privious
- * calls to <CODE>subpixelRefine</CODE>.
- * @param brushsize Halfed diameter of the square shaped brush.
- *
- * @see #segmentate
+ * Set a confidence value at the x,y coordinates to the given value.
+ * If the coordinates are out of range, do nothing.
*/
- void subpixelRefine(int x, int y, int brushmode,
- float threshold, float *cf, int brushsize);
+ virtual void setConfidence(unsigned int x,
+ unsigned int y,
+ float conf);
/**
- * Refines the classification stored in the confidence matrix by modifying
- * the confidences for regions which have characteristics to both
- * foreground and background if they fall into the specified area.
- * <P>
- * The can be used in displaying the image by assigning the alpha values
- * of the pixels according to the confidence entries.
- * <P>
- * In the algorithm descriptions and examples GUIs this step is referrered
- * to as <EM>Detail Refinement (Brush)</EM>.
- *
- * @param area Area in which the reworking of the segmentation is
- * applied to.
- * @param brushmode Mode of the refinement applied, <CODE>ADD_EDGE</CODE>
- * or <CODE>SUB_EDGE</CODE>. Add mode only modifies pixels
- * formerly classified as background, sub mode only those
- * formerly classified as foreground.
- * @param threshold Threshold for the add and sub refinement, deciding
- * at the confidence level to stop at.
- * @param cf The confidence matrix to modify, generated by
- * <CODE>segmentate</CODE>, possibly already refined by privious
- * calls to <CODE>subpixelRefine</CODE>.
- *
- * @see #segmentate
- */
- bool subpixelRefine(int xa, int ya, int dx, int dy,
- int brushmode,
- float threshold, float *cf);
- /**
- * A region growing algorithms used to fill up the confidence matrix
- * with <CODE>CERTAIN_FOREGROUND_CONFIDENCE</CODE> for corresponding
- * areas of equal colors.
- * <P>
- * Basically, the method works like the <EM>Magic Wand<EM> with a
- * tolerance threshold of zero.
- *
- * @param cm confidence matrix to be searched
- * @param image image to be searched
+ * Get a confidence value at the x,y coordinates given. If
+ * the coordinates are out of range, return 0
+ */
+ virtual float getConfidence(unsigned int x, unsigned int y);
+
+ /**
+ * Return the confidence data buffer
+ */
+ virtual float *getConfidenceData();
+
+ /**
+ * Return the width of this image
*/
- void fillColorRegions(float *cm, unsigned long *image);
+ virtual int getWidth();
+
+ /**
+ * Return the height of this image
+ */
+ virtual int getHeight();
+
+ /**
+ * Saves this image as a simple color PPM
+ */
+ bool writePPM(const std::string fileName);
+
+
+
+#ifdef HAVE_GLIB
+
+ /**
+ * Special constructor to create an image from a GdkPixbuf.
+ */
+ SioxImage(GdkPixbuf *buf);
+
+ /**
+ * Creates a GdkPixbuf from this image. The user must
+ * remember to destroy the image when no longer needed.
+ * with g_free(pixbuf)
+ */
+ GdkPixbuf *getGdkPixbuf();
+
+#endif
private:
+ SioxImage()
+ {}
+
/**
- * Prevent this from being used
+ * Assign values to that of another
*/
- SioxSegmentator();
+ void assign(const SioxImage &other);
+
+ /**
+ * Initialize values. Used by constructors
+ */
+ void init(unsigned int width, unsigned int height);
+
+ bool valid;
+
+ unsigned int width;
+
+ unsigned int height;
+
+ unsigned long imageSize;
+
+ /**
+ * Pixel data
+ */
+ unsigned int *pixdata;
+
+ /**
+ * Confidence matrix data
+ */
+ float *cmdata;
+
+private:
+
+ /**
+ * Error logging
+ */
+ void error(const char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+};
+
- /** error logging **/
- void error(char *format, ...);
- /** trace logging **/
- void trace(char *format, ...);
+//########################################################################
+//# S I O X O B S E R V E R
+//########################################################################
+class Siox;
- typedef enum
+/**
+ * This is a class for observing the progress of a Siox engine. Overload
+ * the methods in your subclass to get the desired behaviour.
+ */
+class SioxObserver
+{
+public:
+
+ /**
+ * Constructor. Context can point to anything, and is usually
+ * used to point to a C++ object or C state object, to delegate
+ * callback processing to something else. Use NULL to ignore.
+ */
+ SioxObserver(void *contextArg) : context(NULL)
+ { context = contextArg; }
+
+ /**
+ * Destructor
+ */
+ virtual ~SioxObserver()
+ { }
+
+ /**
+ * Informs the observer how much has been completed.
+ * Return false if the processing should be aborted.
+ */
+ virtual bool progress(float /*percentCompleted*/)
{
- ADD_EDGE, /** Add mode for the subpixel refinement. */
- SUB_EDGE /** Subtract mode for the subpixel refinement. */
- } BrushMode;
+ return true;
+ }
- // instance fields:
+ /**
+ * Send an error string to the Observer. Processing will
+ * be halted.
+ */
+ virtual void error(const std::string &/*msg*/)
+ {
+ }
- /** Horizontal resolution of the image to be segmentated. */
- int imgWidth;
+protected:
- /** Vertical resolution of the image to be segmentated. */
- int imgHeight;
+ void *context;
- /** Number of pixels and/or confidence matrix values to process.
- equal to imgWidth * imgHeight
- */
- long pixelCount;
+};
- /** Stores component label (index) by pixel it belongs to. */
- int *labelField;
+
+
+//########################################################################
+//# S I O X
+//########################################################################
+
+/**
+ *
+ */
+class Siox
+{
+public:
+
+ /**
+ * Confidence corresponding to a certain foreground region (equals one).
+ */
+ static const float CERTAIN_FOREGROUND_CONFIDENCE; //=1.0f;
+
+ /**
+ * Confidence for a region likely being foreground.
+ */
+ static const float FOREGROUND_CONFIDENCE; //=0.8f;
+
+ /**
+ * Confidence for foreground or background type being equally likely.
+ */
+ static const float UNKNOWN_REGION_CONFIDENCE; //=0.5f;
+
+ /**
+ * Confidence for a region likely being background.
+ */
+ static const float BACKGROUND_CONFIDENCE; //=0.1f;
+
+ /**
+ * Confidence corresponding to a certain background reagion (equals zero).
+ */
+ static const float CERTAIN_BACKGROUND_CONFIDENCE; //=0.0f;
+
+ /**
+ * Construct a Siox engine
+ */
+ Siox();
+
+ /**
+ * Construct a Siox engine. Use null to ignore
+ */
+ Siox(SioxObserver *observer);
+
+ /**
+ *
+ */
+ virtual ~Siox();
+
+ /**
+ * Extract the foreground of the original image, according
+ * to the values in the confidence matrix. If the operation fails,
+ * sioxImage.isValid() will be false.
+ * backgroundFillColor is any ARGB color, such as 0xffffff (white)
+ * or 0x000000 (black)
+ */
+ virtual SioxImage extractForeground(const SioxImage &originalImage,
+ unsigned int backgroundFillColor);
+
+private:
+
+ SioxObserver *sioxObserver;
/**
- * LAB color values of pixels that are definitly known background.
- * Entries are of form {l,a,b}.
+ * Progress reporting
*/
- std::vector<CLAB> knownBg;
+ bool progressReport(float percentCompleted);
/**
- * LAB color values of pixels that are definitly known foreground.
- * Entries are of form {l,a,b}.
+ * Flag this as false during processing to abort
*/
- std::vector<CLAB> knownFg;
+ bool keepGoing;
- /** Holds background signature (a characteristic subset of the bg.) */
- std::vector<CLAB> bgSignature;
+ /**
+ * Our signature limits
+ */
+ float limits[3];
+
+ /**
+ * Image width
+ */
+ unsigned int width;
+
+ /**
+ * Image height
+ */
+ unsigned int height;
+
+ /**
+ * Image size in pixels
+ */
+ unsigned long pixelCount;
+
+ /**
+ * Image data
+ */
+ unsigned int *image;
+
+ /**
+ * Image confidence matrix
+ */
+ float *cm;
- /** Holds foreground signature (a characteristic subset of the fg).*/
- std::vector<CLAB> fgSignature;
+ /**
+ * Markup for image editing
+ */
+ int *labelField;
- /** Size of cluster on lab axis. */
- float *limits;
- /** Maximum distance of two lab values. */
+ /**
+ * Maximum distance of two lab values.
+ */
float clusterSize;
/**
- * Stores Tupels for fast access to nearest background/foreground pixels.
+ * Initialize the Siox engine to its 'pristine' state.
+ * Performed at the beginning of extractForeground().
+ */
+ void init();
+
+ /**
+ * Clean up any debris from processing.
+ */
+ void cleanup();
+
+ /**
+ * Error logging
+ */
+ void error(const char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+ /**
+ * Trace logging
*/
- std::map<unsigned long, Tupel> hs;
+ void trace(const char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+ /**
+ * Stage 1 of the color signature work. 'dims' will be either
+ * 2 for grays, or 3 for colors
+ */
+ void colorSignatureStage1(CieLab *points,
+ unsigned int leftBase,
+ unsigned int rightBase,
+ unsigned int recursionDepth,
+ unsigned int *clusters,
+ const unsigned int dims);
+
+ /**
+ * Stage 2 of the color signature work
+ */
+ void colorSignatureStage2(CieLab *points,
+ unsigned int leftBase,
+ unsigned int rightBase,
+ unsigned int recursionDepth,
+ unsigned int *clusters,
+ const float threshold,
+ const unsigned int dims);
+
+ /**
+ * Main color signature method
+ */
+ bool colorSignature(const std::vector<CieLab> &inputVec,
+ std::vector<CieLab> &result,
+ const unsigned int dims);
+
+
+ /**
+ *
+ */
+ void keepOnlyLargeComponents(float threshold,
+ double sizeFactorToKeep);
+
+ /**
+ *
+ */
+ int depthFirstSearch(int startPos, float threshold, int curLabel);
+
+
+ /**
+ *
+ */
+ void fillColorRegions();
+
+ /**
+ * Applies the morphological dilate operator.
+ *
+ * Can be used to close small holes in the given confidence matrix.
+ */
+ void dilate(float *cm, int xres, int yres);
+
+ /**
+ * Applies the morphological erode operator.
+ */
+ void erode(float *cm, int xres, int yres);
+
+ /**
+ * Normalizes the matrix to values to [0..1].
+ */
+ void normalizeMatrix(float *cm, int cmSize);
+
+ /**
+ * Multiplies matrix with the given scalar.
+ */
+ void premultiplyMatrix(float alpha, float *cm, int cmSize);
+
+ /**
+ * Blurs confidence matrix with a given symmetrically weighted kernel.
+ */
+ void smooth(float *cm, int xres, int yres,
+ float f1, float f2, float f3);
+
+ /**
+ * Squared Euclidian distance of p and q.
+ */
+ float sqrEuclidianDist(float *p, int pSize, float *q);
- /** Size of the biggest blob.*/
- int regionCount;
- /** Copy of the original image, needed for detail refinement. */
- long *origImage;
- long origImageSize;
- /** A flag that stores if the segmentation algorithm has already ran.*/
- bool segmentated;
};
-} //namespace siox
-} //namespace org
-#endif /* __SIOX_SEGMENTATOR_H__ */
+
+
+} // namespace siox
+} // namespace org
+
+#endif /* __SIOX_H__ */
+//########################################################################
+//# E N D O F F I L E
+//########################################################################
+
+