/*opencv 头文件*/
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv/cxcore.h"
#include "opencv/cvaux.h"
using namespace cv;
#include <iostream>
using namespace std;
double yz_autoF(IplImage* image);
double yz_autoFSobel(const void* srcarr);
int main()
{
IplImage* previous1;
IplImage* previous2;
IplImage* previous3;
IplImage* previous4;
IplImage* previous5;
IplImage* previous6;
IplImage* previous7;
IplImage* previous8;
IplImage* previous9;
IplImage* previous10;
IplImage* previous11;
IplImage* previous12;
/*previous1=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/9_1600_1200.bmp",1);
previous2=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/7_1600_1200.bmp",1);
previous3=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/11_1600_1200.bmp",1);
previous4=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/12_1600_1200.bmp",1);
previous5=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/13_1600_1200.bmp",1);
previous6=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/14_1600_1200.bmp",1);
previous7=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/15_1600_1200.bmp",1);
previous8=cvLoadImage("D:/vc_2008_pro/7/图像清晰度评价(图像自动聚焦)/1600_1200/8_1600_1200.bmp",1);*/
previous1=cvLoadImage("abbe清晰度/1.bmp",1);
previous2=cvLoadImage("abbe清晰度/2.bmp",1);
previous3=cvLoadImage("abbe清晰度/3.bmp",1);
previous4=cvLoadImage("abbe清晰度/4.bmp",1);
previous5=cvLoadImage("abbe清晰度/5.bmp",1);
previous6=cvLoadImage("abbe清晰度/6.bmp",1);
previous7=cvLoadImage("abbe清晰度/7.bmp",1);
previous8=cvLoadImage("abbe清晰度/8.bmp",1);
previous9=cvLoadImage("abbe清晰度/9.bmp",1);
previous10=cvLoadImage("abbe清晰度/10.bmp",1);
previous11=cvLoadImage("abbe清晰度/11.bmp",1);
previous12=cvLoadImage("abbe清晰度/12.bmp",1);
if(previous1!=0&&previous2!=0&&previous3!=0&&previous4!=0&&
previous5!=0&&previous6!=0&&previous7!=0&&previous8!=0&&
previous9!=0&&previous10!=0&&previous11!=0&&previous12!=0)
{
cvNamedWindow("previous1",1);
cvShowImage("previous1",previous1);
cvNamedWindow("previous2",1);
cvShowImage("previous2",previous2);
cvNamedWindow("previous3",1);
cvShowImage("previous3",previous3);
cvNamedWindow("previous4",1);
cvShowImage("previous4",previous4);
cvNamedWindow("previous5",1);
cvShowImage("previous5",previous5);
cvNamedWindow("previous6",1);
cvShowImage("previous6",previous6);
cvNamedWindow("previous7",1);
cvShowImage("previous7",previous7);
cvNamedWindow("previous8",1);
cvShowImage("previous8",previous8);
cvNamedWindow("previous9",1);
cvShowImage("previous9",previous9);
cvNamedWindow("previous10",1);
cvShowImage("previous10",previous10);
cvNamedWindow("previous11",1);
cvShowImage("previous11",previous11);
cvNamedWindow("previous12",1);
cvShowImage("previous12",previous12);
/*cout<<"The definition of the previous1 is: "<<yz_autoF(previous1)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoF(previous2)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoF(previous3)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoF(previous4)<<endl;
cout<<"The definition of the previous1 is: "<<yz_autoF(previous5)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoF(previous6)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoF(previous7)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoF(previous8)<<endl;
cout<<"The definition of the previous1 is: "<<yz_autoFSobel(previous1)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoFSobel(previous2)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoFSobel(previous3)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoFSobel(previous4)<<endl;
cout<<"The definition of the previous1 is: "<<yz_autoFSobel(previous5)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoFSobel(previous6)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoFSobel(previous7)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoFSobel(previous8)<<endl;*/
/*cout<<"The definition of the previous1 is: "<<yz_autoF(previous1)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoF(previous2)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoF(previous3)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoF(previous4)<<endl;
cout<<"The definition of the previous5 is: "<<yz_autoF(previous5)<<endl;
cout<<"The definition of the previous6 is: "<<yz_autoF(previous6)<<endl;
cout<<"The definition of the previous7 is: "<<yz_autoF(previous7)<<endl;
cout<<"The definition of the previous8 is: "<<yz_autoF(previous8)<<endl;
cout<<"The definition of the previous9 is: "<<yz_autoF(previous9)<<endl;
cout<<"The definition of the previous10 is: "<<yz_autoF(previous10)<<endl;
cout<<"The definition of the previous11 is: "<<yz_autoF(previous11)<<endl;
cout<<"The definition of the previous12 is: "<<yz_autoF(previous12)<<endl;*/
cout<<"The definition of the previous1 is: "<<yz_autoFSobel(previous1)<<endl;
cout<<"The definition of the previous2 is: "<<yz_autoFSobel(previous2)<<endl;
cout<<"The definition of the previous3 is: "<<yz_autoFSobel(previous3)<<endl;
cout<<"The definition of the previous4 is: "<<yz_autoFSobel(previous4)<<endl;
cout<<"The definition of the previous5 is: "<<yz_autoFSobel(previous5)<<endl;
cout<<"The definition of the previous6 is: "<<yz_autoFSobel(previous6)<<endl;
cout<<"The definition of the previous7 is: "<<yz_autoFSobel(previous7)<<endl;
cout<<"The definition of the previous8 is: "<<yz_autoFSobel(previous8)<<endl;
cout<<"The definition of the previous9 is: "<<yz_autoFSobel(previous9)<<endl;
cout<<"The definition of the previous10 is: "<<yz_autoFSobel(previous10)<<endl;
cout<<"The definition of the previous11 is: "<<yz_autoFSobel(previous11)<<endl;
cout<<"The definition of the previous12 is: "<<yz_autoFSobel(previous12)<<endl;
//关掉窗口,结束
cvWaitKey(0);
cvDestroyWindow("previous1");
cvReleaseImage(&previous1);
cvDestroyWindow("previous2");
cvReleaseImage(&previous2);
cvDestroyWindow("previous3");
cvReleaseImage(&previous3);
cvDestroyWindow("previous4");
cvReleaseImage(&previous4);
cvDestroyWindow("previous5");
cvReleaseImage(&previous5);
cvDestroyWindow("previous6");
cvReleaseImage(&previous6);
cvDestroyWindow("previous7");
cvReleaseImage(&previous7);
cvDestroyWindow("previous8");
cvReleaseImage(&previous8);
cvDestroyWindow("previous9");
cvReleaseImage(&previous9);
cvDestroyWindow("previous10");
cvReleaseImage(&previous10);
cvDestroyWindow("previous11");
cvReleaseImage(&previous11);
cvDestroyWindow("previous12");
cvReleaseImage(&previous12);
return 0;
}
return -1;
}
double yz_autoF(IplImage* image)
{
IplImage* picone=cvCreateImage(cvGetSize(image),8,3);
cvCvtColor(image,picone,CV_BGR2YCrCb);
CvScalar gety;
double z=0,zy1=0,zy2=0,total=0;
double gety1=0,gety2=0;
double final1=0;
for(int ix=0;ix<(picone->height);ix++)
{
gety1=0;
gety2=0;
zy1=0;
zy2=0;
for(int jy=0;jy<(picone->width);jy++)
{
gety=cvGet2D(picone,ix,jy);
z=0.5*gety.val[0]-gety1+0.5*gety2+zy1-0.5*zy2;
total=total+z;
gety2=gety1;
gety1=gety.val[0];
zy2=zy1;
zy1=z;
}
}
cvReleaseImage(&picone);
final1=abs(total/((image->height)*(image->width)));
return final1;
}
double yz_autoFSobel(const void* srcarr)
{
CvSize size;
CvMat srcstub, *src = cvGetMat( srcarr, &srcstub );
size = cvGetMatSize( src );
int h,w;
int nPA[9] = {0};
int nHeight = size.heigh
自动对焦.zip_图像清晰度_对焦 梯度_梯度_清晰度_自动对焦
版权申诉
5星 · 超过95%的资源 166 浏览量
2022-07-14
17:17:55
上传
评论 1
收藏 11.75MB ZIP 举报
alvarocfc
- 粉丝: 105
- 资源: 1万+
最新资源
- 机械设计整经机上纱自动化sw20非常好的设计图纸100%好用.zip
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈