How can I get borders and edges for transparent objects

1 view (last 30 days)
%I am trying to get borders for transparent plastic object. but because of uneven light fail to % get it.My code is as follows. Please help
BW = imread('D:\Documents and Settings\sandeep\My Documents\MATLAB\black backgrnd.tif'); BW = rgb2gray(BW); BW = imadjust(BW,[.5 .7],[.3 .9],1.5); thresholdValue = 90;
BW = BW > thresholdValue;
[B,L,N,A] = bwboundaries(BW);
figure; imshow(BW); hold on;
for k=1:length(B),
if(~sum(A(k,:)))
boundary = B{k};
plot(boundary(:,2),...
boundary(:,1),'r','LineWidth',2);
for l=find(A(:,k))'
boundary = B{l};
plot(boundary(:,2),...
boundary(:,1),'g','LineWidth',2);
end
end
end
figure(2), imshow(BW);

Answers (0)

Community Treasure Hunt

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

Start Hunting!