LoG output still very noisy
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
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; }
can you show us your code ? (looks like some pixel-overflow or saturation to me)
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
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.
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.
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.