Commit 09151e85 authored by jaco's avatar jaco

Creation of module's classes'sketetons

parent 91f8d822
set(the_description "Saliency API")
ocv_define_module(saliency)
ocv_define_module(saliency opencv_imgproc)
@startuml
class Algorithm {
}
class Saliency{
String className;
---
+static Ptr<Saliency> create( const String& saliencyType )
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
+String getClassName() const;
}
class Saliency
note right: Saliency is the general interface for each specialized saliency category
class StaticSaliency{
+Params
---
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
class MotionSaliency{
+Params
---
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
class Objectness{
+Params
---
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
class StaticSaliencySpectralResidual{
+Params
---
StaticSaliencySpectralResidual( const SaliencySpectralResidual::Params &parameters);
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
class MotionSaliencyPBAS{
+Params
---
MotionSaliencyPBAS();
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
class ObjectnessBING{
+Params
---
ObjectnessBING();
+bool computeSaliency( const Mat& image, Mat& saliencyMap );
}
Algorithm <|-- Saliency : virtual inheritance
Saliency <|-- StaticSaliency : virtual inheritance
Saliency <|-- MotionSaliency : virtual inheritance
Saliency <|-- Objectness : virtual inheritance
StaticSaliency <|-- StaticSaliencySpectralResidual
MotionSaliency <|-- MotionSaliencyPBAS
Objectness <|-- ObjectnessBING
note "Single instance of the Static Saliency" as N1
note "Single instance of the Motion Saliency" as N2
note "Single instance of the Objectness" as N3
StaticSaliencySpectralResidual .. N1
MotionSaliencyPBAS .. N2
ObjectnessBING .. N3
note "General interface for each specialized type of saliency algorithm" as N4
StaticSaliency .. N4
MotionSaliency .. N4
Objectness .. N4
@enduml
uml @ 4b13f7c0
Subproject commit 4b13f7c043ee897c429d28066c1f4c487d550b0e
......@@ -42,7 +42,8 @@
#ifndef __OPENCV_SALIENCY_HPP__
#define __OPENCV_SALIENCY_HPP__
#include "opencv2/saliency/saliency.hpp"
#include "opencv2/saliency/saliencyBaseClasses.hpp"
#include "opencv2/saliency/saliencySpecializedClasses.hpp"
namespace cv
{
......
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#ifndef __OPENCV_SALIENCY_BASE_CLASSES_HPP__
#define __OPENCV_SALIENCY_BASE_CLASSES_HPP__
#include "opencv2/core.hpp"
#include <opencv2/core/persistence.hpp>
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <sstream>
#include <complex>
namespace cv
{
/************************************ Saliency Base Class ************************************/
class CV_EXPORTS_W Saliency : public virtual Algorithm
{
public:
/**
* \brief Destructor
*/
virtual ~Saliency();
/**
* \brief Create Saliency by saliency type.
*/
static Ptr<Saliency> create( const String& saliencyType );
/**
* \brief Compute the saliency
* \param image The image.
* \param saliencyMap The computed saliency map.
* \return true if the saliency map is computed, false otherwise
*/
bool computeSaliency( const Mat& image, Mat& saliencyMap );
/**
* \brief Get the name of the specific saliency type
* \return The name of the tracker initializer
*/
String getClassName() const;
protected:
virtual bool computeSaliencyImpl( const Mat& image, Mat& saliencyMap ) = 0;
String className;
};
/************************************ Static Saliency Base Class ************************************/
class CV_EXPORTS_W StaticSaliency : public virtual Saliency
{
public:
struct CV_EXPORTS Params
{
Params();
};
//protected:
//virtual bool computeSaliencyImpl( const Mat& image, Mat& saliencyMap ) = 0;
private:
Params params;
};
/************************************ Motion Saliency Base Class ************************************/
class CV_EXPORTS_W MotionSaliency : public virtual Saliency
{
public:
struct CV_EXPORTS Params
{
Params();
};
//protected:
//virtual bool computeSaliencyImpl( const Mat& image, Mat& saliencyMap ) = 0;
private:
Params params;
};
/************************************ Objectness Base Class ************************************/
class CV_EXPORTS_W Objectness : public virtual Saliency
{
public:
struct CV_EXPORTS Params
{
Params();
};
// protected:
// virtual bool computeSaliencyImpl( const Mat& image, Mat& saliencyMap ) = 0;
private:
Params params;
};
} /* namespace cv */
#endif
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#ifndef __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__
#define __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP_
#include "saliencyBaseClasses.hpp"
//TODO delete
#define SALIENCY_DEBUG true
#ifdef SALIENCY_DEBUG
#include <opencv2/highgui.hpp>
#endif
namespace cv
{
/************************************ Specific Static Saliency Specialized Classes ************************************/
/**
* \brief Saliency based on algorithms based on [1]
* [1] Yan, Jia, Xi Chen, and QiuPing Zhu. "Robust online tracking via adaptive samples selection with saliency detection." (2013)
*/
class CV_EXPORTS_W StaticSaliencySpectralResidual : public StaticSaliency
{
public:
struct CV_EXPORTS Params
{
Params();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
StaticSaliencySpectralResidual( const StaticSaliencySpectralResidual::Params &parameters = StaticSaliencySpectralResidual::Params() );
~StaticSaliencySpectralResidual();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
protected:
bool computeKmeans( Mat& saliencyMap, Mat& outputMat );
bool computeSaliencyImpl( const Mat& src, Mat& dst );
AlgorithmInfo* info() const;
private:
Params params;
};
/************************************ Specific Motion Saliency Specialized Classes ************************************/
/**
* \brief Saliency based on algorithms based on [2]
* [2] Hofmann, Martin, Philipp Tiefenbacher, and Gerhard Rigoll. "Background segmentation with feedback: The pixel-based adaptive segmenter."
* Computer Vision and Pattern Recognition Workshops (CVPRW), 2012 IEEE Computer Society Conference on. IEEE, 2012.
*/
class CV_EXPORTS_W MotionSaliencyPBAS : public MotionSaliency
{
public:
struct CV_EXPORTS Params
{
Params();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
//MotionSaliencyPBAS(const MotionSaliencyPBAS::Params &parameters = MotionSaliencyPBAS::Params());
MotionSaliencyPBAS();
~MotionSaliencyPBAS();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
protected:
bool computeSaliencyImpl( const Mat& src, Mat& dst );
AlgorithmInfo* info() const;
private:
Params params;
};
/************************************ Specific Objectness Specialized Classes ************************************/
/**
* \brief Objectness algorithms based on [3]
* [3] Cheng, Ming-Ming, et al. "BING: Binarized normed gradients for objectness estimation at 300fps." IEEE CVPR. 2014.
*/
class CV_EXPORTS_W ObjectnessBING : public Objectness
{
public:
struct CV_EXPORTS Params
{
Params();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
//ObjectnessBING(const ObjectnessBING::Params &parameters = ObjectnessBING::Params());
ObjectnessBING();
~ObjectnessBING();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
protected:
bool computeSaliencyImpl( const Mat& src, Mat& dst );
AlgorithmInfo* info() const;
private:
Params params;
};
} /* namespace cv */
#endif
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#include "precomp.hpp"
namespace cv
{
/**
* PBAS Motion Saliency
*/
/**
* Parameters
*/
MotionSaliencyPBAS::Params::Params()
{
}
MotionSaliencyPBAS::MotionSaliencyPBAS()
{
}
MotionSaliencyPBAS::~MotionSaliencyPBAS()
{
}
void MotionSaliencyPBAS::read( const cv::FileNode& fn )
{
params.read( fn );
}
void MotionSaliencyPBAS::write( cv::FileStorage& fs ) const
{
params.write( fs );
}
bool MotionSaliencyPBAS::computeSaliencyImpl( const Mat& image, Mat& saliencyMap )
{
return true;
}
}/* namespace cv */
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#include "precomp.hpp"
namespace cv
{
/**
* BING Objectness
*/
/**
* Parameters
*/
ObjectnessBING::Params::Params()
{
}
/*ObjectnessBING::ObjectnessBING( const ObjectnessBING &parameters ) :
params( parameters )
{
className = "PBAS";
} */
ObjectnessBING::ObjectnessBING()
{
}
ObjectnessBING::~ObjectnessBING()
{
}
void ObjectnessBING::read( const cv::FileNode& fn )
{
params.read( fn );
}
void ObjectnessBING::write( cv::FileStorage& fs ) const
{
params.write( fs );
}
bool ObjectnessBING::computeSaliencyImpl( const Mat& image, Mat& saliencyMap )
{
return true;
}
}/* namespace cv */
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#include "opencv2/saliency.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#endif
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#include "precomp.hpp"
namespace cv
{
Saliency::~Saliency()
{
}
Ptr<Saliency> Saliency::create( const String& saliencyType )
{
if( saliencyType.find( "STATIC_SALIENCY.SPECTRAL_RESIDUAL" ) == 0 )
{
return Ptr < Saliency > ( new StaticSaliencySpectralResidual() );
}
else if( saliencyType.find( "STATIC_SALIENCY.ITTI_CIO" ) == 0 )
{
//return Ptr < Saliency > ( new SaliencyIttiCIO() );
}
else if( saliencyType.find( "MOTION_SALIENCY.PBAS" ) == 0 )
{
return Ptr < Saliency > ( new MotionSaliencyPBAS() );
}
else if( saliencyType.find( "OBJECTNESS.BING" ) == 0 )
{
return Ptr < Saliency > ( new ObjectnessBING() );
}
CV_Error( -1, "Saliency algorithm type " + saliencyType + " not supported" );
return Ptr<Saliency>();
}
bool Saliency::computeSaliency( const Mat& image, Mat& saliencyMap )
{
if( image.empty() )
return false;
return computeSaliencyImpl( image, saliencyMap );
}
String Saliency::getClassName() const
{
return className;
}
} /* namespace cv */
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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 the copyright holders 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 Intel Corporation or 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.
//
//M*/
#include "precomp.hpp"
namespace cv
{
/**
* SaliencySpectralResidual
*/
/**
* Parameters
*/
StaticSaliencySpectralResidual::Params::Params()
{
}
StaticSaliencySpectralResidual::StaticSaliencySpectralResidual( const StaticSaliencySpectralResidual::Params &parameters ) :
params( parameters )
{
className = "SPECTRAL_RESIDUAL";
}
StaticSaliencySpectralResidual::~StaticSaliencySpectralResidual()
{
}
void StaticSaliencySpectralResidual::read( const cv::FileNode& fn )
{
params.read( fn );
}
void StaticSaliencySpectralResidual::write( cv::FileStorage& fs ) const
{
params.write( fs );
}
bool StaticSaliencySpectralResidual::computeKmeans( Mat& saliencyMap, Mat& outputMat )
{
Mat labels = Mat::zeros( saliencyMap.rows * saliencyMap.cols, 1, 1 );
Mat samples = Mat_<float>( saliencyMap.rows * saliencyMap.cols, 1 );
Mat centers;
TermCriteria terminationCriteria;
terminationCriteria.epsilon = 0.2;
terminationCriteria.maxCount = 1000;
terminationCriteria.type = TermCriteria::COUNT + TermCriteria::EPS;
int elemCounter = 0;
for ( int i = 0; i < saliencyMap.rows; i++ )
{
for ( int j = 0; j < saliencyMap.cols; j++ )
{
samples.at<float>( elemCounter, 0 ) = saliencyMap.at<float>( i, j );
elemCounter++;
}
}
kmeans( samples, 5, labels, terminationCriteria, 5, KMEANS_RANDOM_CENTERS, centers );
outputMat = Mat_<float>( saliencyMap.size() );
int intCounter = 0;
for ( int x = 0; x < saliencyMap.rows; x++ )
{
for ( int y = 0; y < saliencyMap.cols; y++ )
{
outputMat.at<float>( x, y ) = centers.at<float>( labels.at<int>( intCounter, 0 ), 0 );
intCounter++;
}
}
return true;
}
bool StaticSaliencySpectralResidual::computeSaliencyImpl( const Mat& image, Mat& saliencyMap )
{
Mat grayTemp, grayDown;
std::vector<Mat> mv;
Size imageSize( 64, 64 );
Mat realImage( imageSize, CV_64F );
Mat imaginaryImage( imageSize, CV_64F );
imaginaryImage.setTo( 0 );
Mat combinedImage( imageSize, CV_64FC2 );
Mat imageDFT;
Mat logAmplitude;
Mat angle( imageSize, CV_64F );
Mat magnitude( imageSize, CV_64F );
Mat logAmplitude_blur, imageGR;
if( image.channels() == 3 )
{
cvtColor( image, imageGR, COLOR_BGR2GRAY );
resize( imageGR, grayDown, imageSize, 0, 0, INTER_LINEAR );
}
else
{
resize( image, grayDown, imageSize, 0, 0, INTER_LINEAR );
}
grayDown.convertTo( realImage, CV_64F );
mv.push_back( realImage );
mv.push_back( imaginaryImage );
merge( mv, combinedImage );
dft( combinedImage, imageDFT );
split( imageDFT, mv );
//-- Get magnitude and phase of frequency spectrum --//
cartToPolar( mv.at( 0 ), mv.at( 1 ), magnitude, angle, false );
log( magnitude, logAmplitude );
//-- Blur log amplitude with averaging filter --//
blur( logAmplitude, logAmplitude_blur, Size( 3, 3 ), Point( -1, -1 ), BORDER_DEFAULT );
exp( logAmplitude - logAmplitude_blur, magnitude );
//-- Back to cartesian frequency domain --//
polarToCart( magnitude, angle, mv.at( 0 ), mv.at( 1 ), false );
merge( mv, imageDFT );
dft( imageDFT, combinedImage, DFT_INVERSE );
split( combinedImage, mv );
cartToPolar( mv.at( 0 ), mv.at( 1 ), magnitude, angle, false );
GaussianBlur( magnitude, magnitude, Size( 5, 5 ), 8, 0, BORDER_DEFAULT );
magnitude = magnitude.mul( magnitude );
double minVal, maxVal;
minMaxLoc( magnitude, &minVal, &maxVal );
magnitude = magnitude / maxVal;
magnitude.convertTo( magnitude, CV_32F );
resize( magnitude, saliencyMap, image.size(), 0, 0, INTER_LINEAR );
// CLUSTERING BY K-MEANS
Mat outputMat;
computeKmeans( saliencyMap, outputMat );
imshow( "Saliency Map", saliencyMap );
imshow( "K-mean", outputMat );
// FINE CLUSTERING
outputMat = outputMat * 255;
outputMat.convertTo( outputMat, CV_8U );
saliencyMap = outputMat;
return true;
}
}/* namespace cv */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment