i need some help
Mostra commenti meno recenti
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).

Risposta accettata
Più risposte (1)
Walter Roberson
il 27 Mag 2012
0 voti
The code already labels the first car as number 1. It just isn't very good at figuring out what a car is.
1 Commento
Syazwan
il 27 Mag 2012
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!