Glass bottle edge detection using Matlab sofware.
4 views (last 30 days)
Show older comments
ahmad aizat
on 6 Mar 2015
Commented: Image Analyst
on 7 Mar 2015
Hi everyone..i have problem on how to detect the glass bottle by using edge detection method.
As a result..i cant get clear line of the glass bottle mouth and body.. can someone help by checking my code?
this is my code:
I=imread('red5.jpg');
figure, imshow(I);
threshold = graythresh(I);
bw1 = im2bw(I,threshold);
figure, imshow(bw1);
bw2 = bwareaopen(bw1,30);
se = strel('disk',4);
bw3 = imtophat(bw2,se);
figure, imshow(bw3);
d = edge(bw3,'sobel');
figure, imshow(d);
i still new with matlab..any very greatful for those who are helping me..
0 Comments
Accepted Answer
Image Analyst
on 6 Mar 2015
First of all your lighting is horrible. You shouldn't even think about doing anything until you fix your image capture situation . Use lighting that will eliminate shadows and give a nice high contrast edge. After that, it's just simple thresholding.
And I'm not sure what that algorithm is intended to do but it looks like just a bunch of random functions thrown together in random order - not something designed to "detect the glass bottle" like you asked for. I wouldn't do anything like that. I ought to know, since I've been working on image analysis of glasses and bottles for over 20 years (as part of my job).
2 Comments
Image Analyst
on 7 Mar 2015
Once you have the proper lighting you won't need edge detection. Simple thresholding will work:
binaryImage = grayImage < 128; % Or whatever value works.
You should have the sample be in a white light booth, like an integrating sphere, with light bouncing all around and coming at the bottle from every possible angle. Like a white cylinder or box painted white on the inside with the camera overhead (like you have it already).
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!