Ask Your Question

zuba's profile - activity

2014-03-27 11:40:52 -0600 commented answer Blurring issues (only 1/3 of the image is blurred)

Thank you. All I had to do was to add the CV_LOAD_IMAGE_GRAYSCALE in the imread statement and now works great! Or 0 as you said correctly!

2014-03-27 09:47:37 -0600 received badge  Critic (source)
2014-03-27 09:47:32 -0600 received badge  Supporter (source)
2014-03-27 09:45:00 -0600 commented answer Blurring issues (only 1/3 of the image is blurred)

Thank you guys for taking the time to help. Actually I don't know if it would be considered cheating to use a built in function instead of doing our own loop. The image I am imreading is a gray image by the way. The assignment is about averaging the image , each pixel with its 8 neighbors....(3x3)

In other words what exactly do I have to do to fix the issue in my coding? I am too new to programming! :(

2014-03-26 23:31:30 -0600 asked a question Blurring issues (only 1/3 of the image is blurred)

Hello, I am trying for days to figure out what the prolem is in my loop or blurring function. I get only the right 1/3 of the image blurred. Please help!

void Blurring (const Mat& input, Mat& output)
{

      float sum;
      float neighborhood[3][3] = {
                            {1/9.0, 1/9.0, 1/9.0},
                            {1/9.0, 1/9.0, 1/9.0},
                            {1/9.0, 1/9.0, 1/9.0}
                           }; 

       for(int y = 0; y < input.rows; y++)
            for(int x = 0; x < input.cols; x++)
                output.at<unsigned char>(y,x) = 0.0;
                output = input.clone();

        //bluring operation
       for(int y = 1; y < input.rows - 1; y++){
            for(int x = 1; x < input.cols - 1; x++){
                sum = 0.0;
                for(int k = -1; k <= 1;k++){
                    for(int j = -1; j <=1; j++){
                        sum = sum + neighborhood[j+1][k+1]*input.at<unsigned char>(y - j, x - k);
                    }
                }
                output.at<unsigned char>(y,x) = sum;
            }
        }
}