高斯模糊的快捷鍵(如何高斯模糊)

發(fā)布時(shí)間:2024-03-08
本文主要介紹高斯模糊的捷徑(如何高斯模糊),下面一起看看高斯模糊的捷徑(如何高斯模糊)相關(guān)資訊。
帶裁剪區(qū)域的高斯模糊函數(shù)的升級(jí)版本。
函數(shù)check_rect是處理剪輯區(qū)域矩形。如果你不 t計(jì)劃剪切,只需將left,top,right,bottom設(shè)置為0;另外,位圖的存儲(chǔ)格式是上下顛倒的。如果是正常裁剪,只需要設(shè)置bottom to bottom即可。
bool check_rect(int width,int height,int left,int top,int right,int bottom){ if(!向左!頂!對(duì)!bottom) {//無(wú)剪裁左= 0;top = 0;右=寬度;底部=高度;返回true}如果(!(右-左)||!(bottom-top)) {//0面積矩形返回false} if(bottom = 0) {//上下反轉(zhuǎn)int h =-bottom-top;底部=高度-頂部;top = bottom-h;} if(right = 0) {//反轉(zhuǎn)左右int w =-right-left;右=寬-左;左=右-w;} left = max(left,0);top = max(top,0);right = min(右,寬);bottom = min(底部,高度);返回true}//快速高斯模糊函數(shù),由sdragonx 2014-08-01 int gauss _ blur(byte _ t * image,//bitmap data int linebytes,// bitmap row bytes,bmp數(shù)據(jù)在windows中是4字節(jié)對(duì)齊的。否則處理非二次圖像會(huì)有偏差,比如int width,// bitmap width int height,// bitmap height int cbyte,//number of color channel int left,// filter clipping area,都是0,表示不裁剪int top,int right,int bottom,float sigma//gaussian coefficient){ int x = 0,y = 0,n =0;int channel = 0;int srcline = 0,dst line = 0;int channel size = 0;int bufsize = 0;float *w1 = null,*w2 = null,* imgbuf = nullint time = 0;# if defined(_ inc _ windows)time = gettickcount;#elif定義的(_ clock _ t)time = clock;# endif if if(!check_rect(width,height,left,top,right,bottom)){ return-1;}//裁剪寬度和高度int rc _ width = right-left;int rc _ height = bottom-top;channel size = rc _ width * rc _ height;bufsize = rc_width rc_height?rc _ width 4 : rc _ height 4;w1 =(float *)malloc(bufsize * sizeof(float));如果(!w1){ return-1;} w2 =(float *)malloc(buf size * sizeof(float));如果(!w2){ free(w1);return-1;} imgbuf =(float *)malloc(channel size * sizeof(float));如果(!img buf){ free(w1);免費(fèi)(w2);return-1;}// -計(jì)算高斯核。浮點(diǎn)q2 = 0,q3 = 0;浮點(diǎn)b0 = 0,b1 = 0,b2 = 0,b3 = 0;浮點(diǎn)b = 0;if(sigma = 2.5f){ q = 0.98711 f * sigma-0.96330 f;} else if((sigma = 0.5f)(sigma 2.5f)){ q = 3.97156f - 4.14554f *(浮點(diǎn))sqrt(1.0f-0.26891 f * sigma);} else { q = 0.1147705018520355224609375 f;} q2 = q * = q * q2b0 =(1.57825 f(2.44413 f * q)(1.4281 f * q2)(0.422205 f * q3));b1 =((2.44413 f * q)(2.85619 f * q2)(1.26661 f * q3));b2 =(-((1.4281 f * q2)(1.26661 f * q3));b3 =((0.422205 f * q3));b = 1.0f-((b1 b2 b3)/b0);b1/= b0;b2/= b0;b3/= b0;// -計(jì)算高斯核的結(jié)尾。通道cbytechannel) {//獲取一個(gè)通道的所有像素值,預(yù)處理src line = top * line bytes left * cbyte channel;dst line = 0;for(y = 0;yrc _ heighty,srcline =linebytes,dstline =rc_width) { for(x=0,n = 0;xrc _ widthx,n = cbyte){(img buf dstline)[x]= float((image src line)[n]);} } for(int x = 0;xrc _ widthx) {//橫向處理w1[0]=(img buf x)[0];w1[1]=(img buf x)[0];w1[2]=(img buf x)[0];for (y=0,n = 0;yrc _ heighty,n = rc _ width){ w1[y 3]= b *(imgbuf x)[n](b1 * w1[y 2]b2 * w1[y 1]b3 * w1[y 0]);} w2[rc _ height 0]= w1[rc _ height 2];w2[rc_h八1]= w1[rc _ height 1];w2[rc _ height 2]= w1[rc _ height 0];for (int y=rc_height-1,n = y * rc _ widthy = 0;- y,n-= rc _ width){(img buf x)[n]= w2[y]= b * w1[y 3](b1 * w2[y 1]b2 * w2[y 2]b3 * w2[y 3]);} }//橫向處理src line = 0;dst line = top * line bytes left * cbyte channel;for(y = 0;yrc _ heighty,src line = rc _ width,dst line = line bytes){//縱向處理//取當(dāng)前行數(shù)據(jù)w1[0]=(imgbuf src line)[0];w1[1]=(img buf src line)[0];w1[2]=(img buf src line)[0];//三點(diǎn)數(shù)據(jù)正向水平處理for(x = 0;xrc _ widthx){ w1[x 3]= b *(img buf srcline)[x](b1 * w1[x 2]b2 * w1[x 1]b3 * w1[x 0]);} w2[rc _ width 0]= w1[rc _ width 2];w2[rc _ width 1]= w1[rc _ width 1];w2[rc _ width 2]= w1[rc _ width 0];//逆向處理for (x=rc_width-1,n = x * cbytex = 0;- x,n-= cbyte){//(img buf srcline)[x]= w2[x]= b * w1[x 3](b1 * w2[x 1]b2 * w2[x 2]b3 * w2[x 3]);(image dst line)[n]= w2[x]= b * w1[x 3](b1 * w2[x 1]b2 * w2[x 2]b3 * w2[x 3]);} }//縱向處理/*/存儲(chǔ)處理后的通道for(int y = 0;yrc _ heighty){ int dst line =(y top)* line bytes left * cbyte;我nt srcline = y * rc _ widthfor (int x=0,n =通道;xrc _ widthx,n = cbyte){(image dst line)[n]=(imgbuf src line)[x];//byte _ edge((img buf src line)[x]);} }//存儲(chǔ)循環(huán)/*/}/通道循環(huán)空閑(w1);w1 =空;免費(fèi)(w2);w2 = null免費(fèi)(imgbuf);imgbuf = null#if defined(_inc_windows)返回gettickcount-time;#elif定義的(_clock_t)返回clock-time;#else返回0;# endif } int gauss _ blur(byte _ t * image,//位圖數(shù)據(jù)int linebytes,//位圖row bytes,bmp數(shù)據(jù)在windows中4字節(jié)對(duì)齊。否則在處理非二次圖像時(shí)會(huì)出現(xiàn)偏差int width,//位圖width int height,//位圖height int cbyte,//顏色通道數(shù)float sigma //高斯系數(shù)){return gauss _ blur (image,line bytes,width,height,cbyte,0,0,0,sigma);}
下面是剪輯效果圖:
文章發(fā)表于2014年8月14日14 : 53 : 35 csdn,現(xiàn)轉(zhuǎn)博客花園。
標(biāo)簽:
位圖剪輯
了解更多高斯模糊的捷徑(如何高斯模糊)相關(guān)內(nèi)容請(qǐng)關(guān)注本站點(diǎn)。
上一個(gè):滴水觀音圖片, 滴水觀音的養(yǎng)殖方法和注意事項(xiàng)
下一個(gè):RC1206DR-075R9L,1206 5.9Ω 0.5%電阻

半導(dǎo)體基礎(chǔ)知識(shí)
polar公司泵的性能如何
簽收法院傳票會(huì)有短信通知嗎
RC-01W5361FTE,F(xiàn) 0201 5.36K現(xiàn)貨購(gòu)買,風(fēng)華0201 5.36KΩ ±1% 1/20W
醉駕處罰金多少錢
榮耀v9網(wǎng)絡(luò)信號(hào)怎么樣,求問(wèn)iphone V版3網(wǎng)手機(jī) 信號(hào)怎么樣
谷歌四件套一鍵安裝包安卓9.0(谷歌4件套一鍵安裝包)
-天津薊州國(guó)際滑雪場(chǎng)門票價(jià)格 附營(yíng)業(yè)時(shí)間
關(guān)于毛細(xì)管網(wǎng)冷暖輻射系統(tǒng),你知道多少?
如何激活電腦上的辦公軟件,office安裝完了要怎么激活
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos