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 Comments

Isn't that vertical distance just the difference in the vertical coordinates of the two corners you've detected?
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
yeah it can be the difference in vertical coordinates too,i think
Then, since you have detected the two corners, can't you just subtract their vertical coordinates?

Sign in to comment.

 Accepted Answer

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 Comments

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).
ok,thank yo so much,ill read it and tell you,thanx
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.
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
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.
thank you so much for your answer,thanx

Sign in to comment.

More Answers (0)

Categories

Asked:

on 4 Oct 2014

Commented:

on 19 Oct 2014

Community Treasure Hunt

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

Start Hunting!