SlideShare a Scribd company logo
1 of 13
Download to read offline
Elijah Willie
February 16, 2015
301193627
Introduction:
In this document I will attempt to devise an algorithm that will be able to efficiently identify
the location of cigarette butts in an image. This algorithm uses segmentation techniques,
enhancement techniques and coloring techniques all present in matlab to aid in locating the
cigarette butts. This algorithm mainly aims to turn the original image to binary image which
is segmented according to color.
Image Processing
The test image(s)
This algorithm (procedure) is intended to create a binary image/mask from the original which is
segmented according to color of the cigarette butts and the edges present in the image which
will prove to be useful later on to sketch out the shapes of the objects still present in the image.
1.1 Color Segmentation and Edge Detection.
For each pixel, if its color is close enough to the target color, take it. The distance is
defined as: Color = ((R-a).^2+(G-b).^2+(B-c).^2).^(1/2) suppose the target color is
(a,b,c). Since butts commonly are white, tan, or both in color, I have designated
them as follows:
White = (255,255,255),
Tan = (191, 153, 78)
Result of Tan filter:
Result of White Filter:
BW2 = (BW < 40) | (BW1 < 40);
Next we further segment the image by selecting only regions of the segmented images with
intensity values below a certain threshold. In this case I chose 40.
Result after threshold segmentation:
As you can see, most of the background noise has been eliminated by the color segmentation
but still some remains.
[~, threshold] = edge(I, 'prewitt');
This array stores all the edges in the image I and the threshold value given by the prewitt filter
after it has been applied to the image. We can now create a binary mask of the image.
BinaryMask = edge(I,'prewitt', threshold)
If the image has a lot of clutter (noise) in the background, it can’t be avoided that the new
BinaryMask will also have those noisy edges in the back ground.
The Binary Mask after prewitt filter has been applied:
As you can see, the edges of the target object has been signaled out. However there is still
some background noise. It has to be minimized as much as possible before trying to enhance
the image. By using the ‘bwareaopen’ function in matlab, it is possible to reduce some of the
noise in the image background by removing all connected objects that fever than a set amount
of pixel. In this case I arbitrarily chose 110 pixels. I also used the ‘imclearborder’ function to
help kill some more noise.
1.2 Binary Image Enhancement
The below processes are done to help smoothen out the image by filling in gaps
between the edges, dilating the edges for a more rigid shape and assigning arbitrary
colors to the various edges for easier detection.
se90 = strel('line', 3, 90); %vertical element.
se0 = strel('line', 3, 0);%horizontal element.
Maksdilated = imdilate(BinaryMask, [se90 se0]);
The strel function creates vertical and horizontal structuring elements that is passed
to the imdilate function to dilate the edges in the binary image.
Result of Dilation:
Maskfilled = imfill(Maksdilated, 'holes');
If the Binary image has any apparent holes between the edges, the imfill function
fills those hole. In the case of this test image, none of the holes were filled, but it
does not cause enough distraction to render the algorithm useless. The algorithm
would function just fine with or without it. I have decided to leave it in.
Masknoborders = imclearborder(Maskfilled, 8);
Masknoborders = bwareaopen(Masknoborders,110);
These function are applied to clear any edges connected to borders in the binary
image. For some images this effectively removes most of the noise only leaving the
cigarette butts with a small amount of background noise.
Result of the previous two functions:
Compared to the previous image, most of the background noise has been eliminated.
We now proceed to again use the strel function to create a diamond structure that will be used
to smoothen out the newly formed binary mask by the imerode function.
seDiamond = strel('diamond',1); %creates a structuring diamond element.
FinalMask = imerode(Masknoborders,seDiamond); %Smoothes out the image.
Result of Diamond smoothing:
Next, the objects (egdes) in the final image are labelled by using random colors to help better
visualize the remaining objects and noise present in the image.
labeledImage = bwlabel(Masknoborders, 8);
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
The bwlabel function labels all the objects (edges) within in the image so that the label2rgb can
assign (in this case) random colors to the labels. It just helps for better visualization.
Result of colored labelled image:
As you can see, the apparent objects (edges) have been labelled with random colors.
2. Final Image
After the image has been processed with the segmentation and enhancement
techniques, all that remains is to output the final image with some sort of signal of
where the objects of interest are in the image. I have not yet managed to effectively
filter out most of the back ground noise as it will be apparent in the test results for the
image. However, I have been able to identify a great majority of the objects of interests
even if they are amongst noisy backgrounds.
I used a loop to iterate over all the edges in the images and highlight them out in blue
including the objects of interest and excess noise present.
BlobBoundaries = bwboundaries(Masknoborders);
Bound_Num = size(BlobBoundaries);
for x = 1 : Bound_Num
thisBoundary = BlobBoundaries{x};
plot(thisBoundary(:,2), thisBoundary(:,1), 'b', 'LineWidth', 2);
end
Test Results:
3. Conclusions
From the test results, it is clear that more work needs to be done to help eliminate the
unwanted noise in the image. I have not yet found a method to do so. I need to take
the shape of the butts into account as I try to minimize the noise. All the methods tried
so far yielded similar results and this was the best of all the possible test results. Maybe
putting a constraint on rectangularity might help to decrease the noise problem.
For now my algorithm will work well for images that do not have a lot of clutter in the
background which will produce noise to distract from the object of interest. If the
background has a lot of clutter, this algorithm will do a decent job of identifying the
butts amongst the noisy background.
This algorithm is limited by how clustered the image background is, and how many
white, tan or both colored objects are present in the image.
Image_processing
Image_processing
Image_processing

More Related Content

What's hot

Image segmentation
Image segmentationImage segmentation
Image segmentationDeepak Kumar
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detectionRumah Belajar
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothningVinay Gupta
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp maskingRavi Teja
 
Data hiding using image interpolation
Data hiding using image interpolationData hiding using image interpolation
Data hiding using image interpolationVikrant Arya
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...mmjalbiaty
 
Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysislalitxp
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processingMohammed Kamel
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transformSimranjit Singh
 
Image representation
Image representationImage representation
Image representationRahul Dadwal
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquesSaideep
 
Histogram equalization
Histogram equalizationHistogram equalization
Histogram equalizationtreasure17
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point ProcessingGayathri31093
 
JonathanWestlake_ComputerVision_Project1
JonathanWestlake_ComputerVision_Project1JonathanWestlake_ComputerVision_Project1
JonathanWestlake_ComputerVision_Project1Jonathan Westlake
 

What's hot (20)

point operations in image processing
point operations in image processingpoint operations in image processing
point operations in image processing
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detection
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 
Edge Detection
Edge Detection Edge Detection
Edge Detection
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 
Data hiding using image interpolation
Data hiding using image interpolationData hiding using image interpolation
Data hiding using image interpolation
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
 
Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysis
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
Image Segmentation
 Image Segmentation Image Segmentation
Image Segmentation
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transform
 
Image representation
Image representationImage representation
Image representation
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Histogram equalization
Histogram equalizationHistogram equalization
Histogram equalization
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point Processing
 
JonathanWestlake_ComputerVision_Project1
JonathanWestlake_ComputerVision_Project1JonathanWestlake_ComputerVision_Project1
JonathanWestlake_ComputerVision_Project1
 

Similar to Image_processing

Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT RoorkeeIntroductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT RoorkeeVinayak Sahai
 
JonathanWestlake_ComputerVision_Project2
JonathanWestlake_ComputerVision_Project2JonathanWestlake_ComputerVision_Project2
JonathanWestlake_ComputerVision_Project2Jonathan Westlake
 
DSP presentation_latest
DSP presentation_latestDSP presentation_latest
DSP presentation_latestHaowei Jiang
 
Dissertation synopsis for imagedenoising(noise reduction )using non local me...
Dissertation synopsis for  imagedenoising(noise reduction )using non local me...Dissertation synopsis for  imagedenoising(noise reduction )using non local me...
Dissertation synopsis for imagedenoising(noise reduction )using non local me...Arti Singh
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docxmercysuttle
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLABvkn13
 
morphological image processing
morphological image processingmorphological image processing
morphological image processingAnubhav Kumar
 
3 ijaems nov-2015-6-development of an advanced technique for historical docum...
3 ijaems nov-2015-6-development of an advanced technique for historical docum...3 ijaems nov-2015-6-development of an advanced technique for historical docum...
3 ijaems nov-2015-6-development of an advanced technique for historical docum...INFOGAIN PUBLICATION
 
Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingDerek Kane
 
BMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialBMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialpotaters
 
Laureate Online Education Internet and Multimedia Technolog.docx
Laureate Online Education    Internet and Multimedia Technolog.docxLaureate Online Education    Internet and Multimedia Technolog.docx
Laureate Online Education Internet and Multimedia Technolog.docxDIPESH30
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancementRamin Anushiravani
 
Machine learning Exam.pdf
Machine learning Exam.pdfMachine learning Exam.pdf
Machine learning Exam.pdfChitra Krystle
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - HanpoHanpo Cheng
 
Project 2-Image_Processng by Anish Hemmady
Project 2-Image_Processng by Anish HemmadyProject 2-Image_Processng by Anish Hemmady
Project 2-Image_Processng by Anish Hemmadyanish h
 
Image processing sw & hw
Image processing sw & hwImage processing sw & hw
Image processing sw & hwamalalhait
 
Honeymoon suite bedroom tutorial ferry
Honeymoon suite bedroom tutorial ferryHoneymoon suite bedroom tutorial ferry
Honeymoon suite bedroom tutorial ferryNomer Adona
 

Similar to Image_processing (20)

Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT RoorkeeIntroductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT Roorkee
 
JonathanWestlake_ComputerVision_Project2
JonathanWestlake_ComputerVision_Project2JonathanWestlake_ComputerVision_Project2
JonathanWestlake_ComputerVision_Project2
 
Poster cs543
Poster cs543Poster cs543
Poster cs543
 
DSP presentation_latest
DSP presentation_latestDSP presentation_latest
DSP presentation_latest
 
Dissertation synopsis for imagedenoising(noise reduction )using non local me...
Dissertation synopsis for  imagedenoising(noise reduction )using non local me...Dissertation synopsis for  imagedenoising(noise reduction )using non local me...
Dissertation synopsis for imagedenoising(noise reduction )using non local me...
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
 
Image inpainting
Image inpaintingImage inpainting
Image inpainting
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
morphological image processing
morphological image processingmorphological image processing
morphological image processing
 
3 ijaems nov-2015-6-development of an advanced technique for historical docum...
3 ijaems nov-2015-6-development of an advanced technique for historical docum...3 ijaems nov-2015-6-development of an advanced technique for historical docum...
3 ijaems nov-2015-6-development of an advanced technique for historical docum...
 
Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image Processing
 
BMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialBMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorial
 
Image Blur.pptx
Image Blur.pptxImage Blur.pptx
Image Blur.pptx
 
Laureate Online Education Internet and Multimedia Technolog.docx
Laureate Online Education    Internet and Multimedia Technolog.docxLaureate Online Education    Internet and Multimedia Technolog.docx
Laureate Online Education Internet and Multimedia Technolog.docx
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancement
 
Machine learning Exam.pdf
Machine learning Exam.pdfMachine learning Exam.pdf
Machine learning Exam.pdf
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - Hanpo
 
Project 2-Image_Processng by Anish Hemmady
Project 2-Image_Processng by Anish HemmadyProject 2-Image_Processng by Anish Hemmady
Project 2-Image_Processng by Anish Hemmady
 
Image processing sw & hw
Image processing sw & hwImage processing sw & hw
Image processing sw & hw
 
Honeymoon suite bedroom tutorial ferry
Honeymoon suite bedroom tutorial ferryHoneymoon suite bedroom tutorial ferry
Honeymoon suite bedroom tutorial ferry
 

More from Elijah Willie

BC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan PresentationBC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan PresentationElijah Willie
 
Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2Elijah Willie
 
Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1Elijah Willie
 
Computational_biology_project_report
Computational_biology_project_reportComputational_biology_project_report
Computational_biology_project_reportElijah Willie
 
Target_heart_rate_monitor
Target_heart_rate_monitorTarget_heart_rate_monitor
Target_heart_rate_monitorElijah Willie
 

More from Elijah Willie (7)

Co-OP Presentation
Co-OP PresentationCo-OP Presentation
Co-OP Presentation
 
BC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan PresentationBC-Cancer ChimeraScan Presentation
BC-Cancer ChimeraScan Presentation
 
Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2Molecular_bilogy_lab_report_2
Molecular_bilogy_lab_report_2
 
Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1Molecular_bilogy_lab_report_1
Molecular_bilogy_lab_report_1
 
Computational_biology_project_report
Computational_biology_project_reportComputational_biology_project_report
Computational_biology_project_report
 
Target_heart_rate_monitor
Target_heart_rate_monitorTarget_heart_rate_monitor
Target_heart_rate_monitor
 
Fin_whales
Fin_whalesFin_whales
Fin_whales
 

Image_processing

  • 1. Elijah Willie February 16, 2015 301193627 Introduction: In this document I will attempt to devise an algorithm that will be able to efficiently identify the location of cigarette butts in an image. This algorithm uses segmentation techniques, enhancement techniques and coloring techniques all present in matlab to aid in locating the cigarette butts. This algorithm mainly aims to turn the original image to binary image which is segmented according to color. Image Processing The test image(s) This algorithm (procedure) is intended to create a binary image/mask from the original which is segmented according to color of the cigarette butts and the edges present in the image which will prove to be useful later on to sketch out the shapes of the objects still present in the image. 1.1 Color Segmentation and Edge Detection. For each pixel, if its color is close enough to the target color, take it. The distance is defined as: Color = ((R-a).^2+(G-b).^2+(B-c).^2).^(1/2) suppose the target color is (a,b,c). Since butts commonly are white, tan, or both in color, I have designated them as follows: White = (255,255,255), Tan = (191, 153, 78)
  • 2. Result of Tan filter: Result of White Filter: BW2 = (BW < 40) | (BW1 < 40); Next we further segment the image by selecting only regions of the segmented images with intensity values below a certain threshold. In this case I chose 40.
  • 3. Result after threshold segmentation: As you can see, most of the background noise has been eliminated by the color segmentation but still some remains. [~, threshold] = edge(I, 'prewitt'); This array stores all the edges in the image I and the threshold value given by the prewitt filter after it has been applied to the image. We can now create a binary mask of the image. BinaryMask = edge(I,'prewitt', threshold) If the image has a lot of clutter (noise) in the background, it can’t be avoided that the new BinaryMask will also have those noisy edges in the back ground. The Binary Mask after prewitt filter has been applied:
  • 4. As you can see, the edges of the target object has been signaled out. However there is still some background noise. It has to be minimized as much as possible before trying to enhance the image. By using the ‘bwareaopen’ function in matlab, it is possible to reduce some of the noise in the image background by removing all connected objects that fever than a set amount of pixel. In this case I arbitrarily chose 110 pixels. I also used the ‘imclearborder’ function to help kill some more noise. 1.2 Binary Image Enhancement The below processes are done to help smoothen out the image by filling in gaps between the edges, dilating the edges for a more rigid shape and assigning arbitrary colors to the various edges for easier detection. se90 = strel('line', 3, 90); %vertical element. se0 = strel('line', 3, 0);%horizontal element. Maksdilated = imdilate(BinaryMask, [se90 se0]); The strel function creates vertical and horizontal structuring elements that is passed to the imdilate function to dilate the edges in the binary image. Result of Dilation: Maskfilled = imfill(Maksdilated, 'holes'); If the Binary image has any apparent holes between the edges, the imfill function fills those hole. In the case of this test image, none of the holes were filled, but it does not cause enough distraction to render the algorithm useless. The algorithm would function just fine with or without it. I have decided to leave it in.
  • 5. Masknoborders = imclearborder(Maskfilled, 8); Masknoborders = bwareaopen(Masknoborders,110); These function are applied to clear any edges connected to borders in the binary image. For some images this effectively removes most of the noise only leaving the cigarette butts with a small amount of background noise. Result of the previous two functions: Compared to the previous image, most of the background noise has been eliminated. We now proceed to again use the strel function to create a diamond structure that will be used to smoothen out the newly formed binary mask by the imerode function. seDiamond = strel('diamond',1); %creates a structuring diamond element. FinalMask = imerode(Masknoborders,seDiamond); %Smoothes out the image.
  • 6. Result of Diamond smoothing: Next, the objects (egdes) in the final image are labelled by using random colors to help better visualize the remaining objects and noise present in the image. labeledImage = bwlabel(Masknoborders, 8); coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); The bwlabel function labels all the objects (edges) within in the image so that the label2rgb can assign (in this case) random colors to the labels. It just helps for better visualization. Result of colored labelled image: As you can see, the apparent objects (edges) have been labelled with random colors.
  • 7. 2. Final Image After the image has been processed with the segmentation and enhancement techniques, all that remains is to output the final image with some sort of signal of where the objects of interest are in the image. I have not yet managed to effectively filter out most of the back ground noise as it will be apparent in the test results for the image. However, I have been able to identify a great majority of the objects of interests even if they are amongst noisy backgrounds. I used a loop to iterate over all the edges in the images and highlight them out in blue including the objects of interest and excess noise present. BlobBoundaries = bwboundaries(Masknoborders); Bound_Num = size(BlobBoundaries); for x = 1 : Bound_Num thisBoundary = BlobBoundaries{x}; plot(thisBoundary(:,2), thisBoundary(:,1), 'b', 'LineWidth', 2); end Test Results:
  • 8.
  • 9.
  • 10. 3. Conclusions From the test results, it is clear that more work needs to be done to help eliminate the unwanted noise in the image. I have not yet found a method to do so. I need to take the shape of the butts into account as I try to minimize the noise. All the methods tried so far yielded similar results and this was the best of all the possible test results. Maybe putting a constraint on rectangularity might help to decrease the noise problem. For now my algorithm will work well for images that do not have a lot of clutter in the background which will produce noise to distract from the object of interest. If the background has a lot of clutter, this algorithm will do a decent job of identifying the butts amongst the noisy background. This algorithm is limited by how clustered the image background is, and how many white, tan or both colored objects are present in the image.