Glass bottle edge detection using Matlab sofware.

9 次查看(过去 30 天)
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..

采纳的回答

Image Analyst
Image Analyst 2015-3-6
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 个评论
ahmad  aizat
ahmad aizat 2015-3-7
thanks for your comment sir..ill try to improve my lightning for image capture soon. actually what im trying to do is to change the image capture using edge detection method like sobel,prewit or robert. for the lightning position on the glass bottle..it should be on the top or in 45 degree? and what do you mean by simple thresholding?
Image Analyst
Image Analyst 2015-3-7
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).

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by