0% found this document useful (0 votes)
102 views8 pages

Blurring An Image

This document discusses blurring an image by averaging pixel colors in a surrounding area. It defines blurring as spreading each pixel into surrounding pixels, making each pixel a mixture of neighbors. Blurring reduces sharpening and improves detection accuracy. There are two types of blurring - grayscale and color. The steps are to traverse pixels, split colors into R, G, B values, calculate the average of surrounding pixels, and assign this average value to each pixel. Pseudocode demonstrates averaging pixel colors in a 3x3 area to blur an image with grayscale or separate color channels. Increasing the window size to 5x5 can further blur the image. Examples show original, color blurred, and grayscale blurred images.

Uploaded by

liferoxs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views8 pages

Blurring An Image

This document discusses blurring an image by averaging pixel colors in a surrounding area. It defines blurring as spreading each pixel into surrounding pixels, making each pixel a mixture of neighbors. Blurring reduces sharpening and improves detection accuracy. There are two types of blurring - grayscale and color. The steps are to traverse pixels, split colors into R, G, B values, calculate the average of surrounding pixels, and assign this average value to each pixel. Pseudocode demonstrates averaging pixel colors in a 3x3 area to blur an image with grayscale or separate color channels. Increasing the window size to 5x5 can further blur the image. Examples show original, color blurred, and grayscale blurred images.

Uploaded by

liferoxs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

BLURRING AN IMAGE

What is a Blur Image?

ORIGINAL IMAGE

BLURRED IMAGE

Definition:-In image terms blurring means that each pixel in the source image gets spread over and mixed into surrounding pixels. Another way to look at this is that each pixel in the destination image is made up out of a mixture of surrounding pixels from the source image.

Why Should we create a Blurred Image?


Blurring an image reduces the sharpening effect, this makes the detection more accurate. There two type of blurring an image
Gray scaled blur. Color blur.

How do we Blur an image?


Steps / Algorithm
Traverse through entire input image array. Read individual pixel color value (24-bit). Split the color value into individual R, G and B 8bit values. Calculate the RGB average of surrounding pixels and assign this average value to it. Repeat the above step for each pixel. Store the new value at same location in output image.

Pseudo Code(Gray scaled blur)


for(int y=1;y<heightOfImage-1;y++) { for(int x=1;x<widthOfImage-1;x++) { sum = 0; for(int yy=y-1;yy<=y+1;yy++) { //this will get the values of surrounding pixels for(int xx=x-1;xx<=x+1;xx++) { like if 1 is the center | 0 0 0 | // Separating RGB col = inPixels[yy][xx]; |0 1 0 | b = col & 0xff; |0 0 0 | g = (col >> 8) & 0xff; Then we will get the average value of all the r = (col >> 16) & 0xff; surrounding zeros 0 and that value will be assign to the centre 1 // adding grayscale component to sum.

sum += (r+g+b)/3; //We are calculating the Average of RGB using grayscale formula.
} } // average of 8 surrounding pixels and center r = g = b = sum / 9; outPixels[y][x] = (b | (g<<8) | (r<<16)); // Storing the calculated values to the output array } }

Pseudo Code(Color blur)


for(int y=1;y<heightOfImage-1;y++) { for(int x=1;x<widthOfImage-1;x++) { sum = 0; for(int yy=y-1;yy<=y+1;yy++) { //this will get the values of surrounding pixels for(int xx=x-1;xx<=x+1;xx++) { like if 1 is the center | 0 0 0 | // Separating RGB col = inPixels[yy][xx]; |0 1 0 | b = col & 0xff; |0 0 0 | g = (col >> 8) & 0xff; Then we will get the average value of all the r = (col >> 16) & 0xff; surrounding zeros 0 and that value will be assign to the centre 1

sumR += r; // We are calculating sum of R Separately. sumG += g; // We are calculating sum of G Separately. sumB += b; // We are calculating sum of B Separately.
} } // average of 8 surrounding pixels and center r = sumR / 9; g = sumG / 9; b = sumB / 9; outPixels[y][x] = (b | (g<<8) | (r<<16)); // Storing the calculated values to the output array } }

In the above example we are doing blur by calculating the average of surrounding 8 pixel that is 3*3 window. To increase the blur effect we can scan surrounding 5 pixel that is 5*5 window.

ORIGINAL IMAGE.

COLOR BLUR IMAGE.

USING 3*3 WINDOW.

GRAYSCALED BLUR IMAGE.

You might also like