www.pudn.com > Image_segment.rar > ImageSegmentation.h


//Copyright (c) 2004-2005, Baris Sumengen 
//All rights reserved. 
// 
// CIMPL Matrix Performance Library 
// 
//Redistribution and use in source and binary 
//forms, with or without modification, are 
//permitted provided that the following 
//conditions are met: 
// 
//    * No commercial use is allowed.  
//    This software can only be used 
//    for non-commercial purposes. This  
//    distribution is mainly intended for 
//    academic research and teaching. 
//    * Redistributions of source code must 
//    retain the above copyright notice, this 
//    list of conditions and the following 
//    disclaimer. 
//    * Redistributions of binary form must 
//    mention the above copyright notice, this 
//    list of conditions and the following 
//    disclaimer in a clearly visible part  
//    in associated product manual,  
//    readme, and web site of the redistributed  
//    software. 
//    * Redistributions in binary form must 
//    reproduce the above copyright notice, 
//    this list of conditions and the 
//    following disclaimer in the 
//    documentation and/or other materials 
//    provided with the distribution. 
//    * The name of Baris Sumengen may not be 
//    used to endorse or promote products 
//    derived from this software without 
//    specific prior written permission. 
// 
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
//HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
//EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
//NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
//MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
//PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
//CONTRIBUTORS BE LIABLE FOR ANY 
//DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
//EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
//OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
//DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
//HOWEVER CAUSED AND ON ANY THEORY OF 
//LIABILITY, WHETHER IN CONTRACT, STRICT 
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
//OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
//OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
//POSSIBILITY OF SUCH DAMAGE. 
 
 
#pragma once 
#ifndef IMAGE_SEGMENTATION_H 
#define IMAGE_SEGMENTATION_H 
 
#include  
 
#include "cimpl.h" 
using namespace CIMPL; 
 
#include "cimpltoolboxes.h" 
using namespace MathCore; 
using namespace Analysis; 
using namespace LevelSetMethods; 
 
namespace ImageProcessing 
{ 
 
	//Histogram(); 
	//HistogramEqualize(); 
 
 
// Bunch of filters 
 
	// Gaussian 
	Matrix Gaussian2D(int side, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix Gaussian2D(int side, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// First derivative of Gaussian 
	Matrix FDGaussian2D(int side, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix FDGaussian2D(int side, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// Second derivative of Gaussian 
	Matrix SDGaussian2D(int side, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix SDGaussian2D(int side, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// Laplacian of Gaussian 
	Matrix LOG(int side, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix LOG(int side, double sigma_x, double angle = 0, double ratio = 1.0); 
 
 
	// Difference of offset Gaussians 
	Matrix DOOG2D(int side, float sigma_x, float offset, float angle = 0, float ratio = 1.0); 
	Matrix DOOG2D(int side, double sigma_x, double offset, double angle = 0, double ratio = 1.0); 
 
	Matrix DOOG2DCentered(int side, float sigma_x, float offset, float angle = 0, float ratio = 1.0); 
	Matrix DOOG2DCentered(int side, double sigma_x, double offset, double angle = 0, double ratio = 1.0); 
 
 
// Filter image with these filters 
 
	Matrix FilterGaussian2D(Matrix& image, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix FilterGaussian2D(Matrix& image, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// First derivative of Gaussian 
	Matrix FilterFDGaussian2D(Matrix& image, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix FilterFDGaussian2D(Matrix& image, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// Second derivative of Gaussian 
	Matrix FilterSDGaussian2D(Matrix& image, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix FilterSDGaussian2D(Matrix& image, double sigma_x, double angle = 0, double ratio = 1.0); 
 
	// Laplacian of Gaussian 
	Matrix FilterLOG(Matrix& image, float sigma_x, float angle = 0, float ratio = 1.0); 
	Matrix FilterLOG(Matrix& image, double sigma_x, double angle = 0, double ratio = 1.0); 
	 
	// Difference of offset Gaussians 
	Matrix FilterDOOG2D(Matrix& image, float sigma_x, float offset, float angle = 0, float ratio = 1.0); 
	Matrix FilterDOOG2D(Matrix& image, double sigma_x, double offset, double angle = 0, double ratio = 1.0); 
 
	Matrix FilterDOOG2DCentered(Matrix& image, float sigma_x, float offset, float angle = 0, float ratio = 1.0); 
	Matrix FilterDOOG2DCentered(Matrix& image, double sigma_x, double offset, double angle = 0, double ratio = 1.0); 
 
 
 
// Several Edge Detectors 
	 
	// Some filter outputs 
	//EdgeCanny(); 
	//EdgeNitzberg(); 
	//EdgeEdgeflow(); 
 
	// non-maxima suppression 
	Matrix NonMaximaSuppress(Matrix& edgesMain, Matrix& vectorX, Matrix& vectorY); 
	Matrix NonMaximaSuppress(Matrix& edgesMain, Matrix& vectorX, Matrix& vectorY); 
 
	Matrix NonMaximaMask(Matrix& edges, Matrix& vectorX, Matrix& vectorY); 
	Matrix NonMaximaMask(Matrix& edges, Matrix& vectorX, Matrix& vectorY); 
 
	float Direction(float y, float x); 
	double Direction(double y, double x); 
 
	//Threshold(); 
	// hystherisys threshold (see Canny) 
	//HystThreshold(); 
 
 
 
	// Edge tracing from non-maxima suppressed or thresholded edges. 
	//TraceEdges(); 
 
	// Peron-Malik's Anisotropic diffusion 
	Matrix& PMAnisoDiff(Matrix& image, float K, int iterations); 
	Matrix& PMAnisoDiff(Matrix& image, double K, int iterations); 
	MatrixList& PMAnisoDiff(MatrixList& image, float K, int iterations); 
	MatrixList& PMAnisoDiff(MatrixList& image, double K, int iterations); 
 
// Texture 
	//GaborFilters(); 
	//GaborFilterOutputs(); 
 
// Edgeflow 
 
	// both grayscale and multi-valued 
	MatrixList EdgeflowVectorField(Matrix& image, int angles, float sigma, float offset, float ratio = 1.0, bool normalized = true); 
	//MatrixList EdgeflowVectorField(Matrix& image, int angles, double sigma, double offset, double ratio = 1.0, bool normalized = true); 
	MatrixList EdgeflowVectorField(MatrixList& image, int angles, float sigma, float offset, float ratio, bool normalized); 
 
	Matrix CreateFlowImage(Matrix& xFlow, Matrix& yFlow); 
 
	// Edgeflow-based Anisotropic diffusion 
	Matrix& EFAnisoDiff(Matrix& image, Matrix& u, Matrix& v, Matrix& g, int iterations); 
	Matrix& EFAnisoDiff(Matrix& image, Matrix& u, Matrix& v, Matrix& g, int iterations); 
	MatrixList& EFAnisoDiff(MatrixList& image, Matrix& u, Matrix& v, Matrix& g, int iterations); 
	MatrixList& EFAnisoDiff(MatrixList& image, Matrix& u, Matrix& v, Matrix& g, int iterations); 
 
 
	Matrix GetEgdes(Matrix &grads, Matrix &thick, Matrix &suppressed); 
 
	float Angle(float x1, float y1, float x2,  float y2); 
	void RGB2Lab(double R, double G, double B, double &L, double &a, double &b); 
	void Lab2RGB(double L, double a, double b, double &R, double &G, double &B); 
	MatrixList RGB2Lab(MatrixList input); 
	MatrixList Lab2RGB(MatrixList input); 
 
	Matrix SegmentEF(Matrix &im, bool normalized, float initScale, float scaleJump, float endScale,  
		float angleLimit, float ratioLimit, float smoothWeighting, float stopError, int accuracy); 
 
	Matrix SegmentEF(MatrixList &im, bool normalized, float initScale, float scaleJump, float endScale,  
		float angleLimit, float ratioLimit, float smoothWeighting, float stopError, int accuracy); 
 
// Curve evolution stuff 
 
 
 
 
 
 
// GPAC 
 
 
 
 
 
}; 
 
 
#endif