Home > Computer science essays > Efficient method of detecting edges in an image with a lot of objects

Essay: Efficient method of detecting edges in an image with a lot of objects

Essay details and download:

  • Subject area(s): Computer science essays
  • Reading time: 13 minutes
  • Price: Free download
  • Published: 21 June 2022*
  • Last Modified: 29 September 2024
  • File format: Text
  • Words: 3,533 (approx)
  • Number of pages: 15 (approx)

Text preview of this essay:

This page of the essay has 3,533 words.

PART A

ABSTRACT

This report describes an efficient method of detecting edges in an image with a lot of objects. It outlines the effect of noise of different variances on the image and develops noise removal methodology to restore the image to its original form. It examines the result of edge detection on the original image and the image where noise has been removed. All the algorithms and results obtained in this report are developed and tested using on MATLAB.

INTRODUCTION

Edge Detection is integral to image processing in many facets. The task assigned is critically based on analysing the edges detected in an orange image before and after noise is added to the image. The edge detected is observed with different threshold values and an optimal threshold is determined. It also involves inputting a Gaussian noise with variances of 0.026 and 0.1 to the image and further devising a noise removal technique to act on the image restoring it back to its original form. Further investigation is carried out to determine if the detected edge of the cleaned signal can be improved on.

Figure 1. Block diagram showing an overview of the processes in this report.

EXPERIMENTS AND METHODOLOGY

The experiment conducted throughout this report has been conducted on MATLAB. And various tasks given have been highlighted and the methodology implemented has been outlined below.

Loading image into MATLAB and transforming image to grayscale form to manipulate the image and hasten period of implementation.

To load the image in MATLAB, the image is read from a specific directory. The image on which work is carried out is Oranges. The image is converted to grayscale to hasten time of computation when operating in MATLAB. Converting an image to grayscale transforms it from a 3-dimensional to a 2-dimensional image. Figure 2 depicts the transformation of the image from RGB to grayscale.

Figure 2. Original Image assigned and its Grayscale Transformation.

Application of edge detection algorithm to the image. Observation of the resulting edge with different threshold values and determine the optimal threshold for the edge detection.

In application of edge detection algorithm, from Figure 12., various algorithm such as Sobel, Prewitt, Roberts, including Zero Crossing were varied but the best edges were observed from the Canny Edge Detection algorithm.
In justification of the algorithm used, from observation on several images as well as research, Canny edge detection algorithm works appropriately where there are many objects in the image as this was carried out on several images before the decision to use canny algorithm was made.

Canny edge detection algorithm can identify weak edges and the image worked on has the tendency of providing weak edges due to the cluster of objects in the image.

The Canny edge detection algorithm examines partial maximum value for the gradient of the image. The derivative of the Gauss filter counts the image gradient. The Canny edge detection algorithm implements two thresholds to identify strong and weak edges. The weak edges are observed in the output if there is a connection with the strong edge. Canny operator basis is as shown below;

Gauss: g(x,y)=exp⁡[(-(x^2+y^2))/(2σ^2 )] (1)

Edge Normals: n_T= (∇(g*P))/(|∇(g*P)|)
(2)

Edge Strengths: G_n P=∂/(∂n_T )[g*P]

(3)

Maximal Strengths: 0= ∂/(∂n_T )* G_n P= ∂^2/(∂〖n_T〗^2 ) [g*P]
(4)

To determine the optimal threshold, the histogram was analysed due to more benefits. Gradient analysis was conducted on the image histogram. Histogram delivers a description of the appearance of the image. It is the spread of intensity values across the various pixels of the image. From Figure 11., because the image is a grayscale image, intensity values on the histogram ranges from 0 to 255.

From observation of the pattern of edges detected at several threshold values, the optimal Threshold resolved is 0.1.

Figure 3. Canny Edge Detection with Optimal Threshold of 0.1.

Addition of noise with given noise variances to the image and Analysis of the detected edge using the optimal threshold level.
The noise assigned is the Gaussian Noise with variances 0.026 and 0.1. Gaussian noise is defined by summing each image pixel a value from a zero-mean Gaussian distribution.

Gaussian noise is a common noise which is steadily distributed over the signal. This implies that for a pixel in the noisy image, it is the totality of the actual pixel value and a random Gaussian distributed noise value. Gaussian noise possesses a Gaussian distribution and from Figure 4. has a bell-shaped probability distribution function given by,

F(g)= 1/√(2πσ^2 ) e^((-〖(g-m)〗^2)/(2σ^2 )) (5)

g = gray level,
m = mean or average of the function
σ= standard deviation of the noise.
σ^2 = variance

Graphically, it is represented as shown below
.
Figure 4. Bell-shaped Probability Distribution of Gaussian Noise.

The Peak Signal to Noise Ratio (PSNR) is an important factor when describing the effect noise has on an image. From the values observed as inputted in the result, the PSNR of an image decreases as the variance of the noise increases.
The Peak Signal to Noise Ratio (PSNR) and Mean Square Error (MSE) of the noised image is calculated and it operates as a quantitative standpoint for comparison. The Peak Signal to Noise Ratio (PSNR) is usually utilized as a portion of excellence of reconstruction in image noise removal operation.
PSNR=10 log_10⁡(〖〖MAX〗_I〗^2/MSE) (6)

=20 log_10⁡(〖MAX〗_I/√MSE) (7)

=20 log_10⁡(〖MAX〗_I )-10 log_10⁡(MSE) (8)

〖MAX〗_I = maximum pixel value of the image.
MSE=1/mn ∑_(i=0)^(m-1)▒∑_(j=0)^(n-1)▒[I(i,j)-K(i,j)]^2 (9)

MSE = mean square error
I = input image
R = reconstructed image
m = number of pixel in vertical dimension of images I and R
n = number of pixel in horizontal dimension of images I and R

From Figure 6., the edges detected were noisy and not as defined as the edges detected on the image without noise. About the variances, the higher variance of 0.1 had greater noise than the variance of 0.026.

Figure 5. Noised Images with Variances of 0.026 and 0.1.

Figure 6. Canny Edge Detection of the Noised Image with optimal Threshold of 0.1.

Formulation of a noise removal methodology to improve the image and restore it to its initial form. Application of formulated noise removal technique to the image.

The zero-mean property of the zero-mean Gaussian distribution allows the Gaussian noise to be removed by balancing the pixel values. From observation on work on the image, the normal linear filters like the arithmetic mean filter and Gaussian filter cleans the noise nevertheless the edges ended up blurred. From research, to protect the totality of the edges and the information from the Gaussian noise, the wiener filter provides a better result. The wiener filter can be comprehended more effectively in the frequency domain. Computation of the Wiener filter involves a presumption that the signal and noise processes are second-order. With the noisy image, X_((m,n)), discrete Fourier transform is implemented to obtainX_((u,v)). The original image spectrum, S_((u,v)) is approximated by obtaining the product of X_((u,v)) with the Wiener FilterG_((u,v)).
〖Image Spectrum,S〗_((u,v))=G_((u,v) )*X_((u,v))
(10)

The Wiener Filter,G(u,v)=(H_((u,v))* 〖P_1〗_((u,v)))/( 〖〖|H|〗_((u,v))〗^2 *〖P_1〗_((u,v) )+〖P_2〗_((u,v)) ) (11)

H_((u,v)) = Fourier Transform of Point-spread Function (PSF)
〖P_1〗_((u,v)) = Power spectrum of the signal process, from the Fourier Transform of the signal autocorrelation.
〖P_2〗_((u,v))= Power spectrum of the noise process, from the Fourier Transform of the noise autocorrelation.
Dividing through by 〖P_1〗_((u,v))
G(u,v)=H_((u,v))/( 〖〖|H|〗_((u,v))〗^2+〖P_2〗_((u,v))/〖P_1〗_((u,v) ) ) (12)

¬¬ 〖P_2〗_((u,v))/〖P_1〗_((u,v) ) =1/SNR (13)

Figure 7. Denoised Images with Variances of 0.026 and 0.1.

Application of edge detection algorithm with the determined optimal threshold level to denoised image. Comparison of the results with the result of the noised image.

From Figure 8., the detected edges of the image after noise removal are not as distinct as the edges detected in figure 3.

Nevertheless, the edges detected are more defined than the edges detected in the Figure 6., because the wiener filter has acted on the noisy image and created better structured edges. The edges detected from the image with variance of 0.026 is better defined than that of variance of 0.1 because even after denoising the image, due to a higher variance, the pixels of the image are not well defined as that of variance of 0.026.

Figure 8. Canny Edge Detection of the Denoised Image with optimal Threshold of 0.1.

Investigation to determine if the detected edge of the cleaned signal can be improved by varying the threshold level.

By varying the threshold level, it is observed that the detection of edges improved by reducing the values of threshold but the edges did not exactly conform to the edges of the Original images.

Variance 0.026

Threshold 0.2 Threshold 0.07
Figure 9. Edge Detection of Image of Variance 0.026 with threshold of 0.2 and Threshold 0.07.
Variance 0.1

Threshold 0.2 Threshold 0.07
Figure 10. Edge Detection of Image of Variance 0.1 with threshold of 0.2 and Threshold 0.07.
From Figure 9., the greater threshold of 0.2 produced decent edges compared to image of threshold 0.07. Same outcome is observed from Figure 10., for denoised image having original variance of 0.1

RESULTS

Figure 11. Plot of Grayscale Image.

Figure 12. Result of Prewitt, Sobel, Robert Edge Detection on the Grayscale Image.

From Figure 12., the detected edges are not distinct because the weaker edges are not properly detected.

Figure 13. Flow Diagram of Typical Threshold Decision.

Figure 14. Plot of Noised Images

Variance (sq units) PSNR (dB)
0.026 16.9754
0.1 11.9643

Table 1. Table of PSNR for the different noise variances of the Noised Images.

Figure 15. Plot of Denoised Image

Variance (sq units) PSNR (dB)
0.026
0.1

Table 2. Table of PSNR for the different noise variances of the Denoised Images.

DISCUSSION

From Figure14., the plot which is the plot of the noised image depicts a structure different from the plot in Figure 11., because of the noise which has altered the image and caused an even distribution of intensity across the pixels.

The plot observed from Figure 15., which is the plot of the denoised image is a bit like the plot observed in Figure 11., the original image signifying that to some extent the image has been improved to portray the properties of its original form.

Table 1., shows the peak signal to noise ratio value of the noised image of different variances shows that the image produced a high value when compared to the values obtained in Table 2., which holds values for the denoised images signifying that noise has been reasonably reduced.

PART B

EDGE DETECTION

Edge detection is a method of processing images to discover the outer limits (edges) of objects in the images. It operates by identifying lack of continuity in brightness. Edge detection is used to segment image and extract data in diverse fields like image processing, computer vision, machine vision, etc. Edge detection is an important field in image processing. The common edge detection examples are canny, Sobel, Laplace, Roberts, Prewitt, etc. The four stages to edge detection include smoothing, enhancement, detection and localization. Smoothing reduces noise without extinguishing the true edges. Enhancement also referred to as sharpening adds a filter to improve the quality of limits (edges) in an image. Detection resolves which edge pixel should be rejected as noise and which should be accepted. (In most cases, thresholding supplies the criterion used for detection). And localization resolves the precise location of the limit (edge).

NEURAL NETWORK

Neural Network more appropriately referred to as artificial neural network (ANN) is a system made up of several simple, highly interconnected processing elements that transform information by their dynamic state response to external inputs. ANNs are developed to generate an output of a required program automatically. It is created from the basis of human neuron reactions. The capacity of a human to give immediate reflexes has been integral to the development of ANN.
Neural networks are naturally arranged in layers. Layers comprises of several interconnected nodes. Figure 7.1. depicts the basic structure of the ANN with several nodes. These nodes have an activation function. Patterns are processed to the network through the input layer, which communicates to one or more hidden layers where the actual processing is carried out through a system of different specific connections.

Figure 16. Basic ANN Structure.

EDGE DETECTION USING AN ARTIFICIAL NEURAL NETWORK (ANN)

Artificial Neural Networks are known to be relevant in edge detection. There are several Artificial Neural Network models used for detecting edges. They include the convolutional neural network, cellular neural network, feed forward neural network, back propagation neural network, novel neural network, etc. The back propagation is the most commonly utilised technique of training the artificial neural network. Basically, the neural networks based edge detection involves initializing the weight, feeding the training sample, propagating the inputs, updating the inputs, propagation in the hidden layer, and output formation. The major implementation of the artificial neural network is the training to develop algorithm. The training examples have inputs and they are patterned to develop output. To detect edges in an image using artificial neural network, several techniques can be implemented. The input image is processed based on the training implemented for the network, the input is processed in the hidden layer involving several interchanging of information and an output is fed from the output layer. Figure 7.2 is an artificial neural network based edge detection structure having a 9 node input layer (g1, g2,…, g9), with a multiple node hidden layer and a cell output layer.

Figure 17. Layered Artificial Neural Network based Edge Detection Structure.
.
Figure 18. Qualitative Comparison of Results of Edge Detection.

ADVANTAGES OF ANN BASED EDGE DETECTION

Artificial Neural Network technology is better than the conventional edge detection techniques in various perspectives. These include;

Provision of reduced operation load and possesses more benefits for reducing the impact of noise in an image.

Improved adaptive learning capacity. This is achieved as neural network is trained to detect edges in grayscale images possessing unchanging contrast, it can be retrained to resolve images having changing contrast with small changes in lightening environments as neural networks have the capacity to change in real time its synaptic weight.

Capacity to detect edges of the images that are not encountered during the training (learning) phase. This is the generalization ability.

The nonlinear mapping ability. An artificial neuron can as well as being linear be nonlinear. Non–linearity is a significant quality, especially if the primary physical structure responsible for the input image generation is characteristically non-linear.
Artificial neural networks are advantageous because several inputs and several outputs can be implemented during the stage of training. For example, in conventional methods one pixel is processed at a time, whereas in artificial neural networks several pixels as inputs can be processed. This is called parallel organization.

Artificial neural networks are fault tolerant in nature as its performance reduces delicately under adverse conditions.

Another area begging improvement is the optimality criterion as the MSE is not always the best optimality criterion.

CONCLUSION AND FUTURE WORK

Effectively, a human observer can distinguish and define parts of an object by its outline. It can be achieved if it is accurately outlined and if it reflects the form of the object. For the vision system of a machine the task of recognition has been addressed with a similar procedure. This encouraged the development of several edge detection algorithms.

Edge detection generally reduces the quantity of data, filters unnecessary information and equally preserves significant structural qualities in an image. The gradient edge detection method through the maximum and minimum in the first derivative of an image detects the edges. And the Laplacian method looks for zero crossing in the second derivative of an image to locate edges. The

Robert, Sobel and Prewitt operators are gradient edge detection examples.

Edge detection is relevant in the reduction of the dimension of data, in the security of content information, in the inspection for lost portions and calculation of significant part dimension. Further relevance may include the recognition and authentication of electronic user interface display, detection of object and tracking objects.

An area that can be improved is the de-noising around the edges as the technique used did not provide excellent edges after noise removal as the Original Edge.

REFERENCES

Dahl, G., 2015. The Basics of Neural Networks. [Online]
Available at: http://pages.cs.wisc.edu/~bolo/shipyard/neural/local.html
[Accessed 10 March 2017].

Dass, A., Shial, R. & Gouda, B., 2012. Improvising MSN and PSNR for Finger-Print Image noised by GAUSSIAN and SALT & PEPPER. The International Journal of Multimedia & Its Applications (IJMA), 4(4), pp. 59-72.

Folorunsho, O. & Akinwale, A., 2010. A Cellular Neural Network- Based Model for Edge Detection. Journal of Information and Computing Science, V(1), pp. 03-10.

Gupta, J., Choudhary, K. & Singh, K., 2012. Image De-noising by Various Filters for Different Noise using MATLAB, s.l.: s.n.

Kale, U. & Deokar, S., 2014. An Edge Detection Method Using Back Propagation Neural Network. International Journal of Engineering Research and Applications, Issue 12, pp. 07-11.

Krenker, A. & Bešter, J., 2011. Artificial Neural Networks. 1st ed. Rijeka: Intech.

MathWorks, 2017. Edge Detection. [Online]
Available at: https://uk.mathworks.com/discovery/edge-detection.html
[Accessed 10 March 2017].

Trucco, E. & Verri, A., 1998. Introductory Techniques for 3-D Computer Vision. 2nd ed. New Jersey: Prentice Hall.

Vijaykumar, V., Vanathi, P. & Kanagasabapathy, P., 2010. Fast and Efficient Algorithm to Remove Gaussian Noise in Digital Images. International Journal of Computer Science , pp. 10-17.

Yadav, D. & Gupta , P., 2013. Implementing Edge Detection for Medical Diagnosis of a Bone in Matlab. International Conference on Computational Intelligence and Communication Networks, pp. 270-275.

APPENDIX

clc;
clear all;
close all;

% Reads the image from a specific directory
Oranges= imread(\’C:\\MATLAb\\Oranges.jpg\’);
% Converts the read image into grayscale
GrayscaleOranges=rgb2gray(Oranges);
%Displays the properties of the Image
whos GrayscaleOranges
a= imhist (GrayscaleOranges);
plot (a); %Displays a plot of the grayscale

% Displays the image that has been read and the converted image
figure, subplot(1,2,1), imshow (Oranges), title(\’Original Image\’,\’FontSize\’,22);
subplot(1,2,2), imshow (GrayscaleOranges), title(\’Grayscale Image\’,\’FontSize\’,22);

%specifies the canny edge detection method.
CannyEdge= edge(GrayscaleOranges,\’canny\’,0.1);
% Displays the Detected Edge
figure, imshow(CannyEdge), title (\’Canny Edge Detection\’, \’FontSize\’, 22);

%specifies the prewitt, sobel, and roberts edge detection method.
PrewittEdge= edge(GrayscaleOranges,\’prewitt\’,0.1);
SobelEdge= edge(GrayscaleOranges,\’sobel\’,0.1);
RobertsEdge= edge(GrayscaleOranges,\’roberts\’,0.1);

% Displays the Detected Edges
figure, imshow(PrewittEdge), title (\’Prewitt Edge Detection\’, \’FontSize\’, 22);
figure, imshow(SobelEdge), title (\’Sobel Edge Detection\’, \’FontSize\’, 22);
figure, imshow(RobertsEdge), title (\’Robert Edge Detection\’, \’FontSize\’, 22);

%specifies Noise with variance of 0.026
NoiseImage1= imnoise(GrayscaleOranges,\’gaussian\’,0,0.026);
%specifies Noise with variance of 0.1
NoiseImage2= imnoise(GrayscaleOranges,\’gaussian\’,0,0.1);

% Displays the noisy image
figure, subplot (1,2,1), imshow (NoiseImage1), title (\’Noise Variance 0.026\’, \’FontSize\’, 22);
subplot (1,2,2), imshow (NoiseImage2), title (\’Noise Variance 0.1\’, \’FontSize\’, 22);

%specifies the histogram
b1= imhist (NoiseImage1);
b2= imhist (NoiseImage2);
%plots the histogram
plot(b1,b2)

%specifies the Noisy edge detection
NoisyEdge1= edge(NoiseImage1,\’canny\’,0.1);
NoisyEdge2= edge(NoiseImage2,\’canny\’,0.1);

% Displays the detected edge
figure, subplot (1,2,1), imshow (NoisyEdge1), title (\’Edge Detection for 0.026\’, \’FontSize\’, 22);
subplot (1,2,2), imshow (NoisyEdge2), title (\’Edge Detection for 0.1\’, \’FontSize\’, 22);

%specifies the peak signal noise ratio
[peaksnr1, snr1] = psnr(NoiseImage1, GrayscaleOranges);
[peaksnr2, snr2] = psnr(NoiseImage2, GrayscaleOranges);

%displays the calculated value
fprintf(\’\\n The Peak-SNR value is %0.4f\’, peaksnr1);
fprintf(\’\\n The SNR value is %0.4f \\n\’, snr1);
fprintf(\’\\n The Peak-SNR value is %0.4f\’, peaksnr2);
fprintf(\’\\n The SNR value is %0.4f \\n\’, snr2);

% Denoises the noised image
DenoisedImage1= wiener2 (NoiseImage1,[9 9]);
DenoisedImage2= wiener2 (NoiseImage2, [9 9]);

% Displays the denoised image
figure, subplot (1,2,1), imshow (DenoisedImage1), title (\’Denoised Image for 0.026\’, \’FontSize\’, 22)
subplot (1,2,2), imshow (DenoisedImage2), title (\’Denoised Image for 0.1\’, \’FontSize\’, 22)

%specifies the histogram
c1= imhist (DenoisedImage1);
c2= imhist (DenoisedImage2);
%plots the histogram
plot (c1,c2)

%specifies the detected edge
DenoisyEdge1= edge(DenoisedImage1,\’canny\’,0.1);
DenoisyEdge2= edge(DenoisedImage2,\’canny\’,0.1);

%Displays the detected edge
figure, subplot(1,2,1), imshow (DenoisyEdge1), title (\’Edge Detection of Denoised Image of Variance 0.026\’, \’FontSize\’, 22);
subplot(1,2,2), imshow (DenoisyEdge2), title (\’Edge Detection of Denoised Image of Variance 0.1\’, \’FontSize\’, 22);

%specifies the peak signal noise ratio
[peaksnr3, snr3] = psnr(DenoisedImage1, GrayscaleOranges);
[peaksnr4, snr4] = psnr(DenoisedImage2, GrayscaleOranges);

%displays the calculated value
fprintf(\’\\n The Peak-SNR value is %0.4f\’, peaksnr3);
fprintf(\’\\n The SNR value is %0.4f \\n\’, snr3);
fprintf(\’\\n The Peak-SNR value is %0.4f\’, peaksnr4);
fprintf(\’\\n The SNR value is %0.4f \\n\’, snr4);

%specifies the edges of image1 for improvement with threshold
DenoisyEdgeX1= edge(DenoisedImage1,\’canny\’,0.2);
DenoisyEdgeX2= edge(DenoisedImage1,\’canny\’,0.07);

%display the images
imshow (DenoisyEdgeX1)
imshow (DenoisyEdgeX2)

%specifies the edges of image2 for improvement with threshold
DenoisyEdgeY1= edge(DenoisedImage2,\’canny\’,0.2);
DenoisyEdgeY2= edge(DenoisedImage2,\’canny\’,0.07);

%display the images
imshow (DenoisyEdgeY1)
imshow (DenoisyEdgeY2)

LIST OF FIGURES

Figure 1. Block diagram showing an overview of the processes in this report. 3
Figure 2. Original Image assigned and its Grayscale Transformation. 3
Figure 3. Canny Edge Detection with Optimal Threshold of 0.1. 4
Figure 4. Bell-shaped Probability Distribution of Gaussian Noise. 5
Figure 5. Noised Images with Variances of 0.026 and 0.1. 5
Figure 6. Canny Edge Detection of the Noised Image with optimal Threshold of 0.1. 6
Figure 7. Denoised Images with Variances of 0.026 and 0.1. 6
Figure 8. Canny Edge Detection of the Denoised Image with optimal Threshold of 0.1. 7
Figure 9. Edge Detection of Image of Variance 0.026 with threshold of 0.2 and Threshold 0.07. 7
Figure 10. Edge Detection of Image of Variance 0.1 with threshold of 0.2 and Threshold 0.07. 7
Figure 11. Plot of Grayscale Image. 8
Figure 12. Result of Prewitt, Sobel, Robert Edge Detection on the Grayscale Image. 8
Figure 13. Flow Diagram of Typical Threshold Decision. 8
Figure 14. Plot of Noised Images 9
Figure 15. Plot of Denoised Image 9
Figure 16. Basic ANN Structure. 11
Figure 17. Layered Artificial Neural Network based Edge Detection Structure. 11
Figure 18. Qualitative Comparison of Results of Edge Detection. 12

LIST OF TABLES

Table 1. Table of PSNR for the different noise variances of the Noised Images. 9
Table 2. Table of PSNR for the different noise variances of the Denoised Images. 9
PART A

2017-3-16-1489704528

About this essay:

If you use part of this page in your own work, you need to provide a citation, as follows:

Essay Sauce, Efficient method of detecting edges in an image with a lot of objects. Available from:<https://www.essaysauce.com/computer-science-essays/efficient-method-of-detecting-edges-in-an-image-with-a-lot-of-objects/> [Accessed 20-12-24].

These Computer science essays have been submitted to us by students in order to help you with your studies.

* This essay may have been previously published on EssaySauce.com and/or Essay.uk.com at an earlier date than indicated.