資源簡介
使用遞歸高斯模糊算法實現了高斯模糊,比傳統的卷積運算快很多倍,圖片越大優勢越明顯;比FFT快3倍。
目前最快的高斯模糊算法。
基于VS2010,C++源碼
代碼片段和文件信息
#define?WIN32_LEAN_AND_MEAN //?trim?the?excess?fat?from?Windows
/*******************************************************************
* Program:?Chapter?7?Bitmap?Example?2
* Author:?Kevin?Hawkins
* Description:?遞歸高斯模糊??2014/4/23?22:00.
********************************************************************/
//////?Defines
#define?BITMAP_ID?0x4D42 //?the?universal?bitmap?ID
//////?Includes
#include? //?standard?Windows?app?include
#include?
#include?
#include?
#include? //?standard?OpenGL?include
#include? //?OpenGL?utilties
#include? //?OpenGL?auxiliary?functions
#include?“opencv2/highgui/highgui.hpp“
#include?“opencv2/imgproc/imgproc.hpp“
#include?
using?namespace?std;
using?namespace?cv;
//////?Global?Variables
HDC?g_HDC; //?global?device?context
bool?fullScreen?=?false; //?true?=?fullscreen;?false?=?windowed
bool?keyPressed[256]; //?holds?true?for?keys?that?are?pressed
int?width?=?512;
int?height?=?512;
//////?Bitmap?Information
BITMAPINFOHEADER bitmapInfoHeader; //?bitmap?info?header
unsigned?char* bitmapData; //?the?bitmap?data
unsigned?char* ????bitmapData2;
//?高斯半徑設置
int?step?=0;
Point2f?srcTri[3];
Point2f?dstTri[3];
Mat?rot_mat(?2?3?CV_32FC1?);
Mat?warp_mat(?2?3?CV_32FC1?);
Mat?src?warp_dst?warp_rotate_dst;
void?IMG_GaussBlur(unsigned?char*?src?unsigned?char*&?dst?int?width?int?height?float?sigma?int?chan);
//?----------------------------------------------
unsigned?int?listbase; //?display?list?base
unsigned?int?CreateBitmapFont(char?*fontName?int?fontSize)
{
HFONT?hFont;?????????//?windows?font
unsigned?int?base;
base?=?glGenLists(96);??????//?create?storage?for?96?characters
if?(stricmp(fontName?“symbol“)?==?0)
{
hFont?=?CreateFont(fontSize?0?0?0?FW_BOLD?FALSE?FALSE?FALSE?SYMBOL_CHARSET?
OUT_TT_PRECIS?CLIP_DEFAULT_PRECIS?ANTIALIASED_QUALITY
FF_DONTCARE?|?DEFAULT_PITCH?fontName);
}
else
{
hFont?=?CreateFont(fontSize?0?0?0?FW_BOLD?FALSE?FALSE?FALSE?ANSI_CHARSET?
OUT_TT_PRECIS?CLIP_DEFAULT_PRECIS?ANTIALIASED_QUALITY
FF_DONTCARE?|?DEFAULT_PITCH?fontName);
}
if?(!hFont)
return?0;
Selectobject(g_HDC?hFont);
wglUseFontBitmaps(g_HDC?32?96?base);
return?base;
}
void?ClearFont(unsigned?int?base)
{
if?(base?!=?0)
glDeleteLists(base?96);
}
void?PrintString(unsigned?int?base?char?*str)
{
if?((base?==?0)?||?(str?==?NULL))
return;
glPushAttrib(GL_LIST_BIT);
glListbase(base?-?32);
glCallLists(strlen(str)?GL_UNSIGNED_BYTE?str);
glPopAttrib();
}
void?CleanUp()
{
ClearFont(listbase);
}
//----------------------------------------------
//?DrawBitmap
//?desc:?draws?the?bitmap?image?data?in?bitmapImage?at?the?location
// ?(350300)?in?the?window.?(350300)?is?the?lower-left?corner
// ?of?the?bitmap.
void?DrawBitmap(long?width?long?height?unsigned
評論
共有 條評論