i need some help
이전 댓글 표시
this is the coding that i have modified..
Gray = rgb2gray(handles.RGB);
axes(handles.axes2);
imshow(Gray);
guidata(hObject, handles);
Binary = handles.RGB;
normalizedThresholdValue = 0.5; % In range 0 to 1.
thresholdValue = normalizedThresholdValue * max(max(Binary)); % Gray Levels.
BW = im2bw(Binary, normalizedThresholdValue); % One way to threshold to binary
handles.BW = BW;
axes(handles.axes2);
imshow(BW);
guidata(hObject, handles);
fill = handles.BW;
handles.fill = imfill(fill, 'holes');
axes(handles.axes2);
imshow(handles.BW);
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
label = handles.fill;
handles.labeledImage = bwlabel(label, 8);
color = handles.labeledImage
coloredLabels = label2rgb (color, 'jet', 'r', 'noshuffle'); % pseudo random color labels
axes(handles.axes3);
imshow(handles.labeledImage),imshow(coloredLabels);
guidata(hObject, handles);
blobMeasurements = regionprops(handles.labeledImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
fontSize = 14; % Used to control size of "blob number" labels put atop the image.
labelShiftX = -7; % Used to align the labels in the centers of the object.
%blobECD = zeros(1, numberOfBlobs);
% Put the labels on the rgb labeled image also.
for k = 1 : numberOfBlobs % Loop through all blobs.
blobCentroid = blobMeasurements(k).Centroid; % Get centroid.
text(blobCentroid(1) + labelShiftX, blobCentroid(2), num2str(k), 'FontSize', fontSize, 'FontWeight', 'Bold');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
however the result turns out like the image shown..
Can anybody help me on how to repair the coding so that the number on labeled image show the correct value.(eg: 1st car is shown as number 1).

채택된 답변
추가 답변 (1개)
Walter Roberson
2012년 5월 27일
0 개 추천
The code already labels the first car as number 1. It just isn't very good at figuring out what a car is.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!