资源简介
图像显著性FT模型的代码,希望对你有帮助
代码片段和文件信息
#include
#include
#include
using namespace cv;
using namespace std;
void BGR2Lab(Mat srcImage vector& vlabImg);//BGR转为Lab空间
void GaussianSmooth(Mat& singleImg);//高斯平滑
int main()
{
Mat srcImage = imread(“E:\\VS2010\\ScratchProject\\SalientDetection\\SalientDetectionFT\\10.jpg“);
Mat srcImg(srcImage.size()CV_8UC3); //如果是灰度图,则先转换为3通道图像
if(srcImage.channels()==1)
cvtColor(srcImagesrcImgCV_GRAY2BGR);
else
srcImg=srcImage.clone();
imshow(“原始图像“ srcImg);
//BGR转为LAB通道
vector vlabImg; //存放lab三通道的值
BGR2Lab(srcImgvlabImg);
//分别求LAB三通道的均值
vector meanVal;
for(int i = 0;i {
Scalar meanVals = mean(vlabImg[i]);
meanVal.push_back(meanVals.val[0]); //求取LAB三通道的均值
}
//分别求LAB三通道的高斯滤波
GaussianSmooth(vlabImg[0]);
GaussianSmooth(vlabImg[1]);
GaussianSmooth(vlabImg[2]);
//求取显著图
Mat tempImg(srcImg.size()CV_64FC1Scalar::all(meanVal[0]));
absdiff(vlabImg[0]meanVal[0]vlabImg[0]); //L通道的 |均值-高斯滤波|
pow(vlabImg[0]2vlabImg[0]); //对以上结果求平方根
tempImg.setTo(meanVal[1]);
absdiff(vlabImg[1]meanVal[1]vlabImg[1]);
pow(vlabImg[1]2vlabImg[1]);
tempImg.setTo(meanVal[2]);
absdiff(vlabImg[2]meanVal[2]vlabImg[2]);
pow(vlabImg[2]2vlabImg[2]);
Mat salientMap(srcImg.size()CV_64FC1Scalar::all(0));
add(vlabImg[0]vlabImg[1]salientMap);
add(vlabImg[2]salientMapsalientMap);
//归一化
normalize(salientMapsalientMap10CV_MINMAX);
//double型图像转为uchar型图像
Mat salientImg(srcImg.size()CV_8UC1Scalar::all(0));
salientMap.convertTo(salientImgCV_8UC12550);
imshow(“salientImg“salientImg);
waitKey(0);
return 0;
}
void BGR2Lab(Mat srcImg vector& vlabImg)//BGR转为Lab空间
{
Mat initImg(srcImg.size()CV_64FC1Scalar::all(0));
for(int i = 0; i {
vlabImg.push_back(initImg);//初始化vlabImg分别存放L A B
}
Mat LImg(srcImg.size()CV_64FC1Scalar::all(0));
Mat AImg(srcImg.size()CV_64FC1Scalar::all(0));
Mat BImg(srcImg.size()CV_64FC1Scalar::all(0));
for(int i = 0; i < srcImg.rows; i++) //行
{
for(int j = 0; j < srcImg.cols; j++) //列
{
int sB = (int)srcImg.at(ij)[0];
int sG = (int)srcImg.at(ij)[1];
int sR = (int)srcImg.at(ij)[2];
//------------------------
// sRGB to XYZ conversion
// (D65 illuminant assumption)
//------------------------
double R = (double)sR/255.0;
double G = (double)sG/255.0;
double B = (double)sB/255.0;
double r g b;
if(R <= 0.04045) r = (double)R/12.92;
else r = pow((R+0.055)/1.0552.4);
if(G <= 0.04045) g = (double)G/12.92;
else g = pow((G+0.055)/1.0552.4);
if(B <= 0.04045) b = (double)B/12.92;
else b = pow((B+0.055)/1.0552.4)
- 上一篇:VTK图形图像开发进阶_高清完整版
- 下一篇:数字图像处理各种算法 C语言实现
相关资源
- 基于STM32的音频信号采样与FFT分析
- FTP客户端源码(c++)
- 基于opencv的模板匹配代码
- opencv图片扫描以及校正
- opencv手部轮廓识别以及轨迹识别
- ftp工具代码
- opencv2 3D标定.cpp
- 基于opencv漫水填充算法综合
- 使用 IBM Rational Systems Developer 和 Rati
- opencv激光中心线的提取
- Microsoft Visual C++ 2005 Redistributable Pack
- 高效FFT的C/C++代码实现包括基2的DIF和
- FFT(快速傅里叶变换)C++源程序
- Microsoft Visual C++ 2010 Redistributable Pack
- OpenCV Computer Vision Application Programming
- 基于图割的图像分割OpenCV+MFC实现
- FFT算法c语言代码
- python 3.8终极大法解决Microsoft Visual C
- 识别魔方颜色
- opencv版俄罗斯方块源码
- VS2013 / MFC + OpenCV 2.4.9实现视频的播放
- Microsoft Visual C++ 20XX运行库合集vc2005
- Microsoft.Visual.C++.NET技术内幕第六版
- Microsoft Visual C++.NET技术内幕
- 粒子滤波器+目标跟踪的C++实现,VS2
- SIFT检测特征点及特征点描述
- 张平OpenCV算法精讲基于python和C++教材
- 信号FFT变换及绘图
- 用C++写的FTP客户端
- 虹膜识别开源代码OSIRIS4.1基于opencv
评论
共有 条评论