This project basically follow the procedures mentioned on the project requirement, i.e. the image is iteratively filtered by a Laplacian of Gaussian (LoG) kernel at different scale. However there are a few highlighted points:
- Instead of filtering the image with a Gaussian kernel then a Laplacian kernel, I used a single LoG filter, which is the convolution of Gaussian and laplacian kernel. The derivation will be given.
- After filtering at various scales and get response image, I searched the local maxima around each pixel's 26 neighbors in 3D space.
- To remove multiple responses at same blob, I check any pair of candidate circle centers to see if they are close to each other, and remove one of them by some criteria.
- To find how significant a candidate blob is, I defined my own criteria, the mean volume of a blob among all scales. If a candidate circle have low score for this criteria, I will regard it as fake circle and remove it from final results. This definition of criteria is subjective and prefer large circles.
Method to create scale space: I used standard method to create scale space - filtring the original image with LoG filter with various scale parameter
. To get normalized LoG filter, I multiply the LoG kernel with scale
The selection of scales are also standard:
. To have a
up to 4 is because the first image have a large scale circle.
Laplacian filtering: Laplacian filter is usually used to detect edges, as it is able to detect the 'zero-crossing' of second derivative of the signal, which is also the extrema of the first derivative. And that extrema happens at the edges. But because it is very sensitive to noise, good practice is to filter image with a Gaussian filter before Laplacian. Because the convolution is associative, we can convolute the two filter first, then use this LoG filter to convolve with original image. This can save computation. We first define the 2D Gaussian as
If we denoise image by a Gaussian filter then use Laplacian, we have
So we can compute the Laplacian of Gaussian function first. For 2nd derivative of
, we have
Compute the 2nd derivative of
in same way, and we get LoG as
Practically, we need to truncate the function and get a 2D window with size
. To approximate the LoG by
principle, I choose the filter window size as
. We also need mormalize the kernel after truncating so all elements in kernel sum up to one. This generate a truncated normalized kernel which has slightly different value with (5) (due to normalization). For
as an example, the LoG kernel I uses is:
0.0239 0.0460 0.0499 0.0460 0.0239
0.0460 0.0061 -0.0923 0.0061 0.0460
0.0499 -0.0923 -0.3182 -0.0923 0.0499
0.0460 0.0061 -0.0923 0.0061 0.0460
0.0239 0.0460 0.0499 0.0460 0.0239
Maximum detection strategy: After filtering with LoG at all scales, I have a 3D response
, which the third dim as the scale form
. To detect the local maximum as candidate of circle center, I search all pixels in all scales. For each pixel, if its response intensity value
is greater than all its neighbors I'll pick it out as an candidate.
Remove fake candidates that close to each other: Because the candidate circle center may not be at exactly same location with true center, there may be multiple fake responses to same circle. A simple method to detect if two candidate
is same blob can be
That is, if the distance between two blobs centers are smaller than the larger circle center (which can be obtained by
), I'll have to remove one of them that has less response at circle center. by this method, I can remove circles with one half overlapped.
Remove fake candidates by blob volume: I also defined a criteria to remove the blob that are not significant enough. Lindeberg (1993) links the blob in different scales and compare the significance of all blobs by looking at the contrast, spatial extent and lifetime. Here we simplified his method and only look at the mean volume of a blob over all scales.
We informally define the volume of a blob (or a circle in 2D) as the volume of the 3D shape if we regard the response value after filtering as the third dimension. We'll see this is the combination of contrast and spatial extent from the formal definition below
is the response at
, N is all the number of scales. The above formula compute the volume of a blob at a scale, and average it over all scales. Because we know the radius from scale, we know the supporting 'base area' of the blob, i.e. the
. A illustration can be found in fig. 1. This criteria is definitely better than just thresholding peak response at blob center. Because the peak response is the 'contrast' of the region, and the average volume includes also take the spatial extent into account. It is worthy noting that this criteria favors big blob, as they have big support area, and can easily have big volume.
In this section, we test the algorithm on the four given images, and also one image I find myself.
a blob in 3d space (x, y, R). R is the response value after LoG filtering. We can see the peak at the blob center looks like the top of a 'hill' Lindeberg (1993)
We first do test on a simple 'onecircle' image and have the results in 2. The filter works well for this simple image. I also plot the reponse of the circle center over all scales, just to get a glimpse how it looks like. The dynamic filtering at all scales can be found at this GIF image: http://www.sci.utah.edu/~weiliu/class/aip/p1/onecircle.png.gif.
Left plot is the filtering response at the best scale
. Because we look for dark circle, we can see the Laplacian filter have positive response at inner side of the circle's edge, which is what we expected. The middle plot is the response at circle center over all scales. This indicates for ideal circle, the response should be like a convex shape, with a peak value at best scale. The right plot is the results, along with the circle raidus computed from scale.
We then move to the multiple circle in the second image. In multiple circle detection results (fig. 3), we notice: Two blob close to each other have interference in higher scale, because they tend to merge and give inaccurate circle center. We can see a blue color circle close to the right plot's center-left region, and the algorithm did not detect the center accurately. I did not deal with this issue in this project, but am aware of one solution Lindeberg (1994) that consider the 'split' or 'merge' of two blobs in adjacent scales.
The dynamic scale-space filtering results can be found at http://www.sci.utah.edu/~weiliu/class/aip/p1/scalespaceTest.png.gif.
The left figure is the detection results, and right plot is the response of all circle center over all scales. The red color in both plot is the last detected circle and its response trend over scales.
For 'sunflower2' image, the results is fig. 4. For this real-world image, the algorithm detected some local maxima as circle center, while these are actually not real circle (from human vision). By using the threshold of (7), I only choose those candidate circle center with big average blob volume as final results. The threshold of the average blob volume is set to
, which is rather ad-hoc procedure.
From the results of fig. 4 we see the false positive mostly come from locations much like real circle. Some triangle, and square shaped region, are detected as circles. To further improve the algorithm, I think we can look at not only the peak (and volume) of the blob, but also the shape of the blob. Since we know the shape of a circle blob after Laplacian filtering, we can compare the candidate blob's shape with ideal shape, and hopefully will remove fake circles originated from other shapes (triangle, square, etc.)
Sunflower image detection results. Besides remove the overlapped candidate blobs by (6), I also compute the average blob volume by (7), and threshold it by 5000. The thresholding is a trade off between false positive and false negative.
The forth image have detection results in fig. 5. We can see because around the arm and chest of the baby, there is a shape that has almost closed boundary and looks very much like a circle. The algorithm ends up detecting it as a circle, hence a false positive. But the false positive circles around the baby's head is not what I expected.
Sunflower3 image detection results. The threshold for averaged volume criteria is also same to previous plot. We can see there are one or two false negative, and 5 or 6 false positive. By setting a larger threshold we definitely can eliminate most of the false positive, but this ad-hoc method does not make much sense, so we just keep a fixed threshold.
The scale-space circle detection is able to detect object at different scale. The tricky part is after finding local maxima as candidate circle's center, how to tell apart the real circle from other shapes with closed boundary like triangle or square. This is not much related to scale-space, but to different response of circles, triangle, squares to Laplacian filtering.
Below is some tests on images of myself. See fig. 6 and 7.
Two planet images I used to detect circles.
Two 'penny' images with gray level flipped. This is used to detect circles with opposite gray level.
- Detecting salient blob-like image structures and their scales with a
scale-space primal sketch: a method for focus-of-attention.
International Journal of Computer Vision, 11
(3): 283–318, 1993.
- Scale-space theory in computer vision.