how to measure distance between corners?

I have detected some corners in labeled images,how can I measure vertical distance between corners,forexample plot a line at the top corner of each labeled image and measure the vertical difference to each other

댓글 수: 4

Guillaume
Guillaume 2014년 10월 4일
Isn't that vertical distance just the difference in the vertical coordinates of the two corners you've detected?
sara
sara 2014년 10월 4일
forexample the top corner of labeled 1 has 3 cm difference with image 2,like height difference of two people,vertical difference,detect max coroner point on head,then measuring difference with the top corner of other labeled images
sara
sara 2014년 10월 4일
yeah it can be the difference in vertical coordinates too,i think
Guillaume
Guillaume 2014년 10월 4일
Then, since you have detected the two corners, can't you just subtract their vertical coordinates?

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2014년 10월 4일

0 개 추천

Just measure the bounding box with regionprops. A full demo is given in my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

댓글 수: 9

sara
sara 2014년 10월 5일
thank you so much for your answer,ill read it,thanx
it detected area,perimeter,entroid,and diameter,now for measuring height difference between labeled images what should I do?it detected 15 objects,and I want 2 of them,which have largerst area than others,.now for measuring their horizontal difference,it is like computing the vertical difference of 2 people standing in different stairs,detecting minimum point of labeled image aand comparing their horizontal difference,if plot a line in min point of each labeled image,measuring the vertical distance
Cancel
The demo cropped out each coin so it must have got the bounding box, meaning the y (line, row) number, and the height for each region. That's all you need to to find location or relative separation isn't it? If not, explain why you can't get what you need from that information.
To find the largest area, or second largest, you can just sort
allAreas = [measurements.Area];
[sortedAreas, sortIndexes] = sort(allAreas, 'Descend');
The area and index of the largest region will be sortedAreas(1) and sortIndexes(1). The area and index of the second largest region will be sortedAreas(2) and sortIndexes(2).
sara
sara 2014년 10월 8일
ok,thank yo so much,ill read it and tell you,thanx
sara
sara 2014년 10월 12일
hi,can you tell me what should I do for measuring height difference of 2 regions?measuring the y(line,row)?or measuring height of each regions,then ill compare it,thanx,.
Ask for the bounding boxes of all the blobs
measurements = regionprops(labeledImage, 'Area', 'BoundingBox');
% Loop extracting height and top row ("line") for each blob.
for k = 1 : length(measurements)
allHeights(k) = measurements(k).BoundingBox(3);
topRows(k) = measurements(k).BoundingBox(2);
end
Now you have the height and top line number for each blob.
sara
sara 2014년 10월 19일
편집: sara 2014년 10월 19일
will it give me the height of each blob?i want the measurement of the space between them,forexample there might be 2 person both 170 centimeters,but one stands on the first stair and the other on the third,so there is about 50 centimeters vertical difference between them,while both have the same height,. should I just add it at the end of the program?i just add this to the end of the codes,and it detects labeled images,area,but wont show height or top line,should I add imshow,or something,
if true
measurements = regionprops(labeledImage, 'Area', 'BoundingBox');
% Loop extracting height and top row ("line") for each blob.
for k = 1 : length(measurements)
allHeights(k) = measurements(k).BoundingBox(3);
topRows(k) = measurements(k).BoundingBox(2);
end
end
I also choose these lines from your code,which is about area,and it detect different labeled iamges,but wont show area,and measuring,or top line
if true
originalImage =rgb2gray(imread('C:\Users\Sara\Desktop\good.jpg'));
figure,imshow(originalImage);
thresholdValue = 100;
binaryImage = originalImage > thresholdValue;
figure,imshow(binaryImage);
labeledImage = bwlabel(binaryImage, 8);
figure,imshow(labeledImage);
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
figure,imshow(coloredLabels);
blobMeasurements = regionprops(labeledImage, originalImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
boundaries = bwboundaries(binaryImage);
numberOfBoundaries = size(boundaries);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
for k = 1 : numberOfBlobs
blobArea = blobMeasurements(k).Area;
end
allBlobAreas = [blobMeasurements.Area];
for k = 1 : numberOfBlobs
thisBlobsBoundingBox = blobMeasurements(k).BoundingBox;
subImage = imcrop(originalImage, thisBlobsBoundingBox);
figure,imshow(subImage);
end
measurements = regionprops(labeledImage, 'Area', 'BoundingBox');
% Loop extracting height and top row ("line") for each blob.
for k = 1 : length(measurements)
allHeights(k) = measurements(k).BoundingBox(3);
topRows(k) = measurements(k).BoundingBox(2);
end
allAreas = [measurements.Area];
[sortedAreas, sortIndexes] = sort(allAreas, 'Descend');
end
Image Analyst
Image Analyst 2014년 10월 19일
To show top lines, use the line() or plot() function on the original (not cropped) image. To display bounding box, use the rectangle() function on the original image, not the cropped subImage.
sara
sara 2014년 10월 19일
thank you so much for your answer,thanx

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기

질문:

2014년 10월 4일

댓글:

2014년 10월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by