Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

How I draw a rectangle by mosaic effect ?

$
0
0
This is my code #include #include using namespace std; using namespace cv; Mat image; char click; Point p1; Point p2; static void onMouse(int event, int x, int y, int, void*) { switch (event) { case CV_EVENT_LBUTTONDOWN: if (click == 0){ // first click top left click = 1; printf("%d %d", x, y); } else { // second click bottom right click = 2; printf("%d %d", x, y); } break; case CV_EVENT_LBUTTONUP: break; } } void blurImage() { // compute the block int Num_cols = (p2.x - p1.x) / block; int Num_row = (p1.x - p2.x) / block; for (int i = 0; i < Num_row; i++) { for(int j = 0; j < Num_cols; j++) { int x1 = p1.x + j * block; int y1 = p1.y + j * block; int avg = sum / block*block; // assign each pixel value by the block value } } int main(void) { image = imread("C:/Users/faho0odywbas/Desktop/test.jpg"); namedWindow("Demo"); setMouseCallback("Demo", onMouse); imshow("Demo", image); waitKey(0); return 0; } I want to draw a rectangle that's blur every thing inside it by mosaic effect, so my question is how to compute the block and assign each pixel value by the block value which are missing on my code So the rectangle will be like this ![image description](/upfiles/14425905441186855.jpg)

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>