欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

OpenCV實(shí)現(xiàn)馬賽克功能-創(chuàng)新互聯(lián)

本文實(shí)例為大家分享了OpenCV實(shí)現(xiàn)馬賽克功能的具體代碼,供大家參考,具體內(nèi)容如下

站在用戶的角度思考問題,與客戶深入溝通,找到枝江網(wǎng)站設(shè)計與枝江網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計制作、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋枝江地區(qū)。

實(shí)現(xiàn)用按下鼠標(biāo)左鍵拖動時,在鼠標(biāo)經(jīng)過的路徑上打上馬賽克。

馬賽克的原理是將圖像中選中區(qū)域的像素用這個選中區(qū)域中的某一像素覆蓋。

為了不讓鼠標(biāo)重復(fù)經(jīng)過圖像中同一個的時候,選取不一樣的像素,該程序?qū)⒃谳斎雸D片的時候,就實(shí)現(xiàn)了全圖的馬賽克效果。而當(dāng)鼠標(biāo)劃過的時候,程序只是將實(shí)現(xiàn)馬賽克的圖片的指定位置復(fù)制到顯示的圖像中。

效果類似于QQ截圖中的馬賽克。

#include <opencv2\core\core.hpp> 
#include <opencv2\highgui\highgui.hpp> 
#include <opencv2\imgproc\imgproc.hpp> 
#include <iostream> 
 
using namespace cv; 
using namespace std; 
 
Mat inputImage; 
Mat inputImage_mosaic; 
Mat inputImage_clone; 
 
//馬賽克的大小 
int neightbourhood = 20; 
 
//記錄鼠標(biāo)的狀態(tài),0為鼠標(biāo)左鍵未按下或彈起,1為鼠標(biāo)左鍵按下 
int mouseStatus = 0; 
 
void onMouse(int events, int x, int y, int flag, void* ustg); 
 
//創(chuàng)建馬賽克圖片 
void createMosaicImage(Mat inputMat, Mat& outputMat, int size); 
 
//設(shè)置馬賽克區(qū)域 
void setMosaic(Mat& inputMat, Rect rect); 
 
int main(void){ 
 inputImage = imread("test2.jpg"); 
 inputImage_clone = inputImage.clone(); 
 createMosaicImage(inputImage, inputImage_mosaic, neightbourhood); 
 
 namedWindow("showImage", 0); 
 setMouseCallback("showImage", onMouse); 
 
 waitKey(); 
 return 0; 
} 
 
void createMosaicImage(Mat inputMat, Mat& outputMat, int size){ 
 RNG rng; 
 int height = inputMat.rows; 
 int width = inputMat.cols; 
 Mat padding; 
 Mat tempMat; 
 
 //為了方便后面的計算,將輸入的圖像大小擴(kuò)充到寬高都是size的倍數(shù) 
 copyMakeBorder(inputMat, padding, 0, size - inputMat.rows % size, 0, size - inputMat.cols % size, BORDER_REPLICATE); 
 tempMat = padding.clone(); 
 
 for (int row = 0; row < padding.rows; row += size){ 
 for (int col = 0; col < padding.cols; col += size){ 
  int rand_x = rng.uniform(0, size); 
  int rand_y = rng.uniform(0, size); 
  Rect rect = Rect(col, row, size, size); 
  Mat roi = tempMat(rect); 
  Scalar color = Scalar(padding.at<Vec3b>(row + rand_y, col + rand_x)[0], \ 
  padding.at<Vec3b>(row + rand_y, col + rand_x)[1], \ 
  padding.at<Vec3b>(row + rand_y, col + rand_x)[2]); 
  roi.setTo(color); 
 } 
 } 
 outputMat = tempMat(Rect(0, 0, width, height)).clone(); 
} 
 
void setMosaic(Mat& inputMat, Rect rect){ 
 Mat roi = inputMat(rect); 
 Mat tempRoi = inputImage_mosaic(rect); 
 tempRoi.copyTo(roi); 
} 
 
void onMouse(int events, int x, int y, int flag, void* ustg){ 
 
 //當(dāng)鼠標(biāo)移除圖片區(qū)域的時候,不做操作 
 if (x < 0 || x > inputImage.cols || y < 0 || y > inputImage.rows){ 
 return; 
 } 
 
 //馬賽克塊的位置信息 
 int x_left, x_right, y_top, y_bottom; 
 x - neightbourhood <= 0 ? x_left = 0 : x_left = x - neightbourhood; 
 x + neightbourhood > inputImage.cols ? x_right = inputImage.cols: x_right = x + neightbourhood; 
 y - neightbourhood <= 0 ? y_top = 0 : y_top = y - neightbourhood; 
 y + neightbourhood > inputImage.rows ? y_bottom = inputImage.rows: y_bottom = y + neightbourhood; 
 
 if (events == CV_EVENT_LBUTTONDOWN){ 
 mouseStatus = 1; 
 setMosaic(inputImage_clone, Rect(x_left, y_top, x_right - x_left, y_bottom - y_top)); 
 } 
 else if (events == CV_EVENT_MOUSEMOVE){ 
 if (mouseStatus == 1){ 
  setMosaic(inputImage_clone, Rect(x_left, y_top, x_right - x_left, y_bottom - y_top)); 
 } 
 else{ 
  //nothing 
 } 
 } 
 else if (events == CV_EVENT_LBUTTONUP){ 
 mouseStatus = 0; 
 } 
 else { 
 //cout << "nothing" << endl; 
 } 
 imshow("showImage", inputImage_clone); 
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站www.aaarwkj.com,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享名稱:OpenCV實(shí)現(xiàn)馬賽克功能-創(chuàng)新互聯(lián)
文章起源:http://www.aaarwkj.com/article32/dpjjpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、ChatGPT、建站公司、動態(tài)網(wǎng)站定制開發(fā)、電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
国内激情自拍偷拍视频| 国产有码日产一区在线观看| 国产精品十八禁在线看| 亚洲一区在线观看激情| 亚洲久久精品中文字幕| 亚洲精品国产高清久久| 熟妇高潮一区二区三区| 中文乱码字幕午夜无线观看| 国产精品美女丝袜久久久| 无码精品人妻一区二区三区中 | 中文字幕中出亚洲精品| 91人妻这里只有精品| 粉嫩国产av一区二区三区| 亚洲一区二区日本乱码| 国产在线精品91国自产拍| 麻豆国产av巨做国产剧情| 中文字幕有码在线朋友| 97乱碰视频在线观看| 给我免费在线观看视频| 欧美伊人久久综合成人网| 激情视频一区二区三区| 欧美一区二区高清不卡| 欧美精品亚洲二区中文乱码| 国产性做爰片免费网站| 亚洲视频一区视频二区| 蜜桃人妻av一区二区三区| 91九色午夜在线观看| 午夜精品三级一区二区三区| 欧美视频综合一级91| 国产性做爰片免费视频| 国产麻豆精品免费喷白浆视频网站| 婷婷色精品一区二区激情| 亚洲激情久热中文字幕| 日本免费观看一区久久| 午夜理论片在线观看有码| 亚洲人成伊人成综合网中文| 亚洲精品一区二区牛仔裤| 深夜视频国产在线观看| 日本色电影一区二区三区| 久久免费欧美日韩亚洲| 免费国产中文字幕黄网站|