資源簡介
開發工具vs2017,opencv+mfc,可以讀取bmp圖片文件,然后對圖片進行加入噪聲,畫取輪廓,像素過濾等操作
代碼片段和文件信息
#include?“stdafx.h“//加到工程后這個就要添上
#include?“CvvImage.h“
?
?
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
?
?
CV_INLINE?RECT?NormalizeRect(RECT?r);
CV_INLINE?RECT?NormalizeRect(RECT?r)
{
int?t;
?
?
if?(r.left?>?r.right)
{
t?=?r.left;
r.left?=?r.right;
r.right?=?t;
}
?
?
if?(r.top?>?r.bottom)
{
t?=?r.top;
r.top?=?r.bottom;
r.bottom?=?t;
}
?
?
return?r;
}
?
?
CV_INLINE?CvRect?RectToCvRect(RECT?sr);
CV_INLINE?CvRect?RectToCvRect(RECT?sr)
{
sr?=?NormalizeRect(sr);
return?cvRect(sr.left?sr.top?sr.right?-?sr.left?sr.bottom?-?sr.top);
}
?
?
CV_INLINE?RECT?CvRectToRect(CvRect?sr);
CV_INLINE?RECT?CvRectToRect(CvRect?sr)
{
RECT?dr;
dr.left?=?sr.x;
dr.top?=?sr.y;
dr.right?=?sr.x?+?sr.width;
dr.bottom?=?sr.y?+?sr.height;
return?dr;
}
?
CV_INLINE?IplROI?RectToROI(RECT?r);
CV_INLINE?IplROI?RectToROI(RECT?r)
{
IplROI?roi;
r?=?NormalizeRect(r);
roi.xOffset?=?r.left;
roi.yOffset?=?r.top;
roi.width?=?r.right?-?r.left;
roi.height?=?r.bottom?-?r.top;
roi.coi?=?0;
return?roi;
}
?
void?FillBitmapInfo(BITMAPINFO*?bmi?int?width?int?height?int?bpp?int?origin)
{
assert(bmi?&&?width?>=?0?&&?height?>=?0?&&?(bpp?==?8?||?bpp?==?24?||?bpp?==?32));
?
BITMAPINFOHEADER*?bmih?=?&(bmi->bmiHeader);
memset(bmih?0?sizeof(*bmih));
bmih->biSize?=?sizeof(BITMAPINFOHEADER);
bmih->biWidth?=?width;
bmih->biHeight?=?origin???abs(height)?:?-abs(height);
bmih->biPlanes?=?1;
bmih->biBitCount?=?(unsigned?short)bpp;
bmih->biCompression?=?BI_RGB;
?
?
if?(bpp?==?8)
{
RGBQUAD*?palette?=?bmi->bmiColors;
int?i;
for?(i?=?0;?i?256;?i++)
{
palette[i].rgbBlue?=?palette[i].rgbGreen?=?palette[i].rgbRed?=?(BYTE)i;
palette[i].rgbReserved?=?0;
}
}
}
?
?
CvvImage::CvvImage()
{
m_img?=?0;
}
?
?
void?CvvImage::Destroy()
{
cvReleaseImage(&m_img);
}
?
?
CvvImage::~CvvImage()
{
Destroy();
}
?
?
bool?CvvImage::Create(int?w?int?h?int?bpp?int?origin)
{
const?unsigned?max_img_size?=?10000;
?
?
if?((bpp?!=?8?&&?bpp?!=?24?&&?bpp?!=?32)?||
(unsigned)w?>=?max_img_size?||?(unsigned)h?>=?max_img_size?||
(origin?!=?IPL_ORIGIN_TL?&&?origin?!=?IPL_ORIGIN_BL))
{
assert(0);?//?most?probably?it?is?a?programming?error
return?false;
}
?
?
if?(!m_img?||?Bpp()?!=?bpp?||?m_img->width?!=?w?||?m_img->height?!=?h)
{
if?(m_img?&&?m_img->nSize?==?sizeof(IplImage))
Destroy();
?
?
/*?prepare?IPL?header?*/
m_img?=?cvCreateImage(cvSize(w?h)?IPL_DEPTH_8U?bpp?/?8);
}
?
?
if?(m_img)
m_img->origin?=?origin?==?0???IPL_ORIGIN_TL?:?IPL_ORIGIN_BL;
?
?
return?m_img?!=?0;
}
?
?
void?CvvImage::CopyOf(CvvImage&?image?int?desired_color)
{
IplImage*?img?=?image.GetImage();
if?(img)
{
CopyOf(img?desired_color);
}
}
?
?
?
?
#define?HG_IS_IMAGE(img)?\
????((img)?!=?0?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????58368??2018-09-13?14:27??opencv_3\.vs\opencv_3\v15\.suo
?????文件???87371776??2018-09-13?14:27??opencv_3\.vs\opencv_3\v15\Browse.VC.db
?????文件??140509184??2018-09-13?14:24??opencv_3\.vs\opencv_3\v15\ipch\2d7f8e0cc7e16ed2.ipch
?????文件??121307136??2018-09-10?10:34??opencv_3\.vs\opencv_3\v15\ipch\4b7e0403624c4457.ipch
?????文件???????6733??2018-09-10?10:59??opencv_3\opencv_3\CvvImage.cpp
?????文件???????1954??2018-09-10?10:59??opencv_3\opencv_3\CvvImage.h
?????文件?????109384??2018-09-13?14:25??opencv_3\opencv_3\opencv3.aps
?????文件??????12256??2018-09-13?14:25??opencv_3\opencv_3\opencv3.rc
?????文件???????4164??2018-09-10?10:31??opencv_3\opencv_3\opencv_3.cpp
?????文件????????816??2018-09-10?10:31??opencv_3\opencv_3\opencv_3.h
?????文件??????10419??2018-09-10?16:27??opencv_3\opencv_3\opencv_3.vcxproj
?????文件???????2180??2018-09-10?10:40??opencv_3\opencv_3\opencv_3.vcxproj.filters
?????文件????????230??2018-09-10?10:40??opencv_3\opencv_3\opencv_3.vcxproj.user
?????文件??????17854??2018-09-13?14:25??opencv_3\opencv_3\opencv_3Dlg.cpp
?????文件???????2566??2018-09-12?14:28??opencv_3\opencv_3\opencv_3Dlg.h
?????文件????????670??2018-09-10?10:32??opencv_3\opencv_3\res\opencv3.rc2
?????文件??????67777??2018-09-04?10:22??opencv_3\opencv_3\res\opencv_3.ico
?????文件???????2152??2018-09-12?14:26??opencv_3\opencv_3\resource.h
?????文件????????226??2018-09-10?10:32??opencv_3\opencv_3\stdafx.cpp
?????文件???????2912??2018-09-10?10:32??opencv_3\opencv_3\stdafx.h
?????文件????????370??2018-09-10?10:32??opencv_3\opencv_3\targetver.h
?????文件??????99075??2018-09-10?16:27??opencv_3\opencv_3\x64\Debug\CvvImage.obj
?????文件??????70024??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv3.res
?????文件????????104??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv_3.log
?????文件?????497610??2018-09-12?14:28??opencv_3\opencv_3\x64\Debug\opencv_3.obj
?????文件???57147392??2018-09-10?16:27??opencv_3\opencv_3\x64\Debug\opencv_3.pch
?????文件???????3126??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv_3.tlog\CL.command.1.tlog
?????文件?????182136??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv_3.tlog\CL.read.1.tlog
?????文件???????3522??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv_3.tlog\CL.write.1.tlog
?????文件???????1988??2018-09-13?14:25??opencv_3\opencv_3\x64\Debug\opencv_3.tlog\li
............此處省略29個文件信息
評論
共有 條評論