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.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; }