資源簡(jiǎn)介
相同條件下拍到的棋盤(pán)圖和日歷鐘表圖,嘗試建立幾何畸變關(guān)系,并對(duì)它們進(jìn)行恢復(fù)。

代碼片段和文件信息
/*--------------------------
Author:?葉耀祖
opencv?version:?opencv343
visual?studio?2017
Date:2018/12/18
EMail:yaozuye@zju.edu.cn
--------------------------*/
#include?
#include?
#include?
#include?
#?include
#define?PI?3.14159
#define?PHOTO_W?644
#define?PHOTO_H?485
#define?PHOTO_AREA?(644*485)
#?define?PARAM_SIZE?8
using?namespace?cv;
using?namespace?std;
const?Point2f?CenterPoint(PHOTO_W?/?2?PHOTO_H?/?2);
void?int2str(const?int?&int_temp?string?&string_temp)
{
stringstream?stream;
stream?< string_temp?=?stream.str();???//此處也可以用?stream>>string_temp??
}
//數(shù)字圖像處理第一次作業(yè)源代碼
void?HK1()
{
Mat?src?=?Mat(256?256?CV_8UC3?Scalar(0?0?0));
Mat?src2?=?Mat(640?640?CV_8UC3?Scalar(0?0?0));
int?radius?=?300;
Point?center?=?Point(320?320);
circle(src2?center?radius?Scalar(255255255)?-1);
Mat?rectDst;
for?(int?i?=?0;?i?256;?i++)
{
for?(int?j?=?0;?j?256;?j++)
{
uchar?Hue?=?uchar(180.0?/?255?*?j);
uchar?Satu?=?255-i?;
uchar?Value?=?255;
src.at(ij)?=?Vec3b(Hue?Satu?Value);
}
}
for?(int?i?=?0;?i?640;?i++)
{
for?(int?j?=?0;?j?640;?j++)
{
if?(src2.at(i?j)?==?Vec3b(255?255?255))
{
int?Hue?=?atan((320?-?i)*1.0?/?(j?-?320))?/?PI?*?180?+?90;
if?(j?320)
{
Hue?+=?180;
}
uchar?cvHue?=?Hue/2;
uchar?saturation?=?1.0*sqrt((320?-?i)*(320?-?i)?+?(j?-?320)*(j?-?320))?/?radius?*?255;
src2.at(i?j)?=?Vec3b(cvHue?saturation?255);
}
}
}
cvtColor(src2?src2?COLOR_HSV2RGB);
cvtColor(src?src?COLOR_HSV2RGB);
imshow(“rect“?src);
imshow(“circle“?src2);
imwrite(“rectDst.bmp“?src);
imwrite(“cirleDst.bmp“?src2);
waitKey(0);
}
bool?absCompare(int?a?int?b)
{
return?abs(a)?}
//kernelSize為濾波器核的邊長(zhǎng),k為近鄰個(gè)數(shù)
void?kNearMean(Mat?&src8uc1?Mat?&dst?int?k?=?1?int?kernelSize?=?3)
{
int?rows?=?src8uc1.rows;
int?cols?=?src8uc1.cols;
int?size?=?(kernelSize?-?1)?/?2;
int?arrLen?=?kernelSize?*?kernelSize?-?1;
//此處使用int是為了累加和減法不會(huì)溢出
int?*sortArray?=?new?int[arrLen];
int?originValue;
for?(int?i?=?size;?i? {
for?(int?j?=?size;?j? {
int?tempIndex?=?0;
originValue?=?int(src8uc1.at(i?j));
for?(int?tempi?=?i?-?size;?tempi?<=?i?+?size;?tempi++)
{
for?(int?tempj?=?j?-?size;?tempj?<=?j?+?size;?tempj++)
{
if?(tempi?!=?i?||?tempj?!=?j)
{
sortArray[tempIndex]?=?int(src8uc1.at(tempi?tempj))?-?int(originValue);
tempIndex++;
}
}
}
sort(sortArray?sortArray?+?arrLen?absCompare);
int?sumTemp?=?0;
for?(int?temp?=?0;?temp? {
sumTemp?+=?sortArray[temp];
}
int?dstValue?=?originValue?+?sumTemp*1.0?/?k;
dst.at(i?j)?=?uchar(dstValue);
}
}
delete[]?sortArray;
}
void?meanFilter(Mat?&src8uc1?Mat?&dst?
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????81004??2018-12-13?20:16??chessGraph.jpg
?????文件??????288256??2018-12-28?22:26??ConfigTest.exe
?????文件???????82539??2018-12-13?20:16??distortion.jpg
?????文件??????121046??2018-12-28?22:28??dst.jpg
?????文件???????13868??2018-12-28?22:26??main.cpp
?????文件?????1917604??2018-12-27?22:45??my_video.avi
?????文件?????1343371??2018-12-29?14:28??opencv角點(diǎn)檢測(cè).png
?????文件?????2021330??2018-12-28?14:44??梯度下降擬合函數(shù).gif
?????文件?????1343371??2018-12-29?14:28??畸變前角點(diǎn).png
?????文件?????1253912??2018-12-27?20:35??結(jié)果圖片.png
- 上一篇:NuSMV-2.6.0-win64.tar.gz
- 下一篇:Badboy安裝包
評(píng)論
共有 條評(píng)論