资源简介
使用VC2010编写,实现了导入多幅图像,显示最清晰的图像
代码片段和文件信息
#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 && ((const IplImage*)(img))->nSize == sizeof(IplImage) && \
((IplImage*)img)->imageData != 0)
void CvvImage::CopyOf( IplImage* img int desired_color )
{
i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6344 2013-04-15 11:53 FousTest\CvvImage.cpp
文件 1875 2013-04-16 15:13 FousTest\CvvImage.h
文件 218112 2013-04-23 16:22 FousTest\Debug\FousTest.exe
目录 0 2013-04-26 14:41 FousTest\Debug
文件 106372 2013-04-23 13:21 FousTest\FousTest.aps
文件 2019 2013-04-17 11:09 FousTest\FousTest.cpp
文件 454 2013-04-17 11:09 FousTest\FousTest.h
..A..H. 40 2013-04-26 14:16 FousTest\FousTest.opensdf
文件 11740 2013-04-23 13:21 FousTest\FousTest.rc
文件 1179 2013-04-23 13:31 FousTest\FousTest.sln
..A..H. 20480 2013-04-23 16:41 FousTest\FousTest.suo
文件 6901 2013-04-17 11:46 FousTest\FousTest.vcxproj
文件 2177 2013-04-17 11:46 FousTest\FousTest.vcxproj.filters
文件 143 2013-04-17 11:09 FousTest\FousTest.vcxproj.user
文件 16254 2013-04-23 13:14 FousTest\FousTestDlg.cpp
文件 1352 2013-04-22 16:18 FousTest\FousTestDlg.h
文件 3032 2013-04-17 11:09 FousTest\ReadMe.txt
文件 67777 2009-08-31 02:31 FousTest\res\FousTest.ico
文件 672 2013-04-17 11:09 FousTest\res\FousTest.rc2
目录 0 2013-04-26 14:41 FousTest\res
文件 2466 2013-04-23 13:21 FousTest\resource.h
文件 141 2013-04-17 11:09 FousTest\stdafx.cpp
文件 1632 2013-04-17 11:09 FousTest\stdafx.h
文件 234 2013-04-17 11:09 FousTest\targetver.h
目录 0 2013-04-26 14:41 FousTest
----------- --------- ---------- ----- ----
471396 25
评论
共有 条评论