Upload
drunkenklown
View
216
Download
0
Embed Size (px)
Citation preview
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 1/6
Colin Patch
V00620013
ELEC536
February 12, 2012
Assignment 2 Part1
1.
For the first question, I used an averaging kernel and the filter2 function as pre-processing to smooth
blocks.png. I then used two kernels
vert = [1,2,1,0,0,0,-1,-2,-1]; horiz = [1,0,-1,2,0,-2,1,0,-1];
and applied them in convolution to the smoothed image. This resulted in two matrices for vertical andhorizontal magnitude. These X and Y directional magnitudes were then combined using G =
sqrt(X^2+Y^2) to find the combined magnitude. The result of this absolute magnitude is shown below in
figure 1.
Figure 1 – Gradient magnitude
To ensure all the values were within a fixed range, the image was converted to intensity values, 0 to 1,
using the mat2gray function. This intensity gradient magnitude image was then converted to binary with
a threshold of 0.09 to give the image in figure 2. Using a low threshold is necessary as the image is quite
dark, a lot of the shape edges are not detected due to the colour and shade being consistent from object
to object and some edges are missed that are at an angle close to 45 degrees. This is because the
gradient kernels are most sensitive to north south, east and west, but less so to directions between:
north-west or south-east. The edge detector worked quite well without too much noise though.
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 2/6
Figure 2 – Binary image of gradient magnitude, threshold = 0.09
2.
For question 2, the directional gradient images, X and Y were used to find magnitude angles. The
arctand (Y/X) function was used to find the angle for each element in degrees and depending on the
quadrant, the value was assigned to 0-90, 90-180, 180-270 or 270-360 (quadrant 1, 2, 3 or 4
respectively). The image was then displayed where 0 degrees is black and 360 is white, as seen in figure
3. After completing the assignment, it was realized that there is no way to differentiate between 0 and
360 degrees, as both the X and Y values will be identical. It is assumed then, that pure black and pure
white are interchangeable in the image. The angles also depend on which direction the edge is being
detected from. From left, the angle might be 0, from the right, the angle might be 180. So it may have
been better to use -90 to 90 degrees to cover all of the angles without added redundancy.
Figure 3 – Directional Gradient image using 0-360 degrees which gives some unwanted
redundancy to the values, ie 180 = 360 = 0, but the image is still readable
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 3/6
3.
The function fspecial was used to create a 3x3 Laplacian kernel. I then used a nested for loop (instead of
conv2) to apply the isotropic kernel convolution giving the resulting image shown in figure 4. Sigma of
0.5 was chosen as it seemed to give more sensitive detection and a sharper image.
Figure 4 – 3x3 Laplacian kernel applied to original image(not smoothed image)
A nested for loop was used to check the north, north west and west neighbours for each pixel to find
sign changes. The image for detected zero crossings is shown in figure 5, where white denotes a zero
crossing. There are a lot of detections because the laplacian method is highly susceptible to noise.
Figure 5 – Binary image of the laplacian using 0.05 threshold to find impulses next to zero crossings
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 4/6
4.
For this question, I used my gradient magnitude binary image and my laplacian detection image and
simply combined the two. Where ever both images contained a 1 for the same indexed element, the
new image would also contain a 1 at that index. In this way, the threshold value for the gradient is
applied to the laplacian detections. Only detections found in BOTH images are kept as detections in the
combined image, giving the image in figure 6. This has greatly cleaned up the laplacian detections and
has also made the gradient image a little sharper and more defined. Some edges are still broken though.
Figure 6 –
Exclusive combined detections from laplacian and gradient binary images
5.
The fspecial function was again used to create 3 new laplacian of Gaussian kernels using sigma values of
0.5, 1 and 5. Using smaller kernels did not blur the image significantly enough, so 15x15 kernels were
chosen arbitrarily and made a much larger impact. A small value of sigma created a sharper image with
many more detections and noise. Larger sigmas blurred the image more which decreased noisy
detections, but also caused the edges to distort and skew. The larger the blur, the less accurate the
edges became, but almost all of the noise induced edges were eliminated. Corners were also sharper
and more accurate with smaller sigma. The following images illustrate the impact of different sigma
values. Sigma=1 gave greater accuracy of edges detection, giving a sharper image of the blocks withsome noise. Sigma of 5 was better for noise reduction, but skewed the edges a little. Optimal sigma for
the 15x15 kernel would have to be 5 or larger, as the edges are accurate enough with much less noise.
Sigma below 1 increased noise, creating almost unusable data. Above 1, the image does not change
noticeably, so sigma=5 will give roughly the same image as a sigma of 10 or 25.
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 5/6
Figure 7a – Sigma = 0.5 Laplacian and its zero detection equivalent, sharper image, much more noise
Figure 7b – Sigma = 1 Laplacian and its zero detection equivalent, less noise, sharp enough
Figure 7c – Sigma = 5 Laplacian and its zero detection equivalent, some distorted edges/corners, least noise
7/29/2019 Assignment 2 p 1
http://slidepdf.com/reader/full/assignment-2-p-1 6/6