LoG output still very noisy

asked 2016-04-03 06:01:44 -0500

Nbb gravatar image

updated 2016-04-08 07:06:18 -0500

Hello,

I am implementing the LoG filter. I smooth the image using a gaussian with sd = 3 before applying the laplacian operator on it. My result is much worse than the one described here

These are my output. The 'grayscale' map looks similar to the one in the link but the final edge map looks horrible. I think it is because of the zero crossing. Could it be because the zero crossing i implemented is not good ? In my implementation, a pixel is a zero crossing if it has a different sign than its neighbour i.e. x vs x + 1 and y vs y + 1. I also suppress the pixels of the LoG output if the intensity is not above a certain value before scanning for the zero crossing. My output still remains horrible

image description

image description

Mat laplacian = (Mat_<int>(3, 3) << 0, -1, 0, -1, 4, -1, 0, -1, 0);    
img = imread("cln1.jpg", CV_LOAD_IMAGE_GRAYSCALE); 
GaussianBlur( img, img, Size(), 13, 13, BORDER_DEFAULT ); 
Mat edgeMap = convolve(input, laplacian, 1); 
output = detectZeroCrossing(edgeMap);

Mat detectZeroCrossing(Mat& image) {

    Mat edgeMap = Mat::zeros(image.rows, image.cols, CV_8UC1);

    int rows = image.rows;  
    int cols = image.cols;

    for (int x = 0; x < rows; x++)      
          for (int y = 0; y < cols; y++)        
          {             
               // Ignore borders            
          if (x + 1 >= image.rows || x - 1 < 0 || y + 1 >= image.cols || y - 1 < 0) continue;

          if ((sgn(image.at<int>(x, y)) != sgn(image.at<int>(x + 1, y)))) 
                       edgeMap.at<uchar>(x, y) = 255;                         
          if ((sgn(image.at<int>(x, y)) != sgn(image.at<int>(x, y + 1)))) 
                       edgeMap.at<uchar>(x, y) = 255;       
          }

    return edgeMap; }

image description

edit retag flag offensive close merge delete

Comments

can you show us your code ? (looks like some pixel-overflow or saturation to me)

berak gravatar imageberak ( 2016-04-03 06:40:00 -0500 )edit

Hi i have added the code. I read in http://www.owlnet.rice.edu/~elec539/P... that i should add some threshold for the zero crossing detection. I am still unable to get a decent output no matter what I try, I have tried the local variance and also the absolute of the difference between the neighbours

Nbb gravatar imageNbb ( 2016-04-03 08:15:43 -0500 )edit

It works slightly better if i smooth the output of the log before detecting the zero crossings. But its not the proper log framework. I am still puzzled at how the algorithm for the zero crossing should look like. It seems like I get a similar problem for a lot of the images I try.

Nbb gravatar imageNbb ( 2016-04-03 22:22:14 -0500 )edit
1

Try setting a threshold in the zero crossing. Where the abs(pixel) has to be above a certain value. In the flat bits you're getting a lot of noise, which is probably very small in magnitude.

Tetragramm gravatar imageTetragramm ( 2016-04-04 19:57:57 -0500 )edit

I have added a threshold to suppress the the pixels of the output of LoG if it is not above a threshold of 3. Im using sigma = 3. The output still looks horrible. And I think the LoG is supposed to give me a thin edges.

Nbb gravatar imageNbb ( 2016-04-08 07:00:09 -0500 )edit