width to height ratio of various images

1 view (last 30 days)
preeti verma
preeti verma on 8 Jan 2021
Commented: KALYAN ACHARJYA on 8 Feb 2021
I want to find width to height ratio of a rectangle which is made around this person as shown in figure, Rectangle just like start from person's forward fingure and end at backward ankle. I have around 80 images so basically want a looping program that gives me all 80 image's width to height ratio of the corrosponding rectangles.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 8 Jan 2021
Edited: KALYAN ACHARJYA on 8 Jan 2021
It seems to be a project related task (not homework), so I have answered it
Supposedly, you have that red markers in the image, if not then also, you can apply the simmiler apprach to get maximum and minimum pixels positions in the segmented image. The challenge is not associated with achieving length and width, the main challenge is to properly divide ROI (Getting ROI's boundary pixels properly), if all other images have the same poor illumination and vice versa, there may be a possibility to fit a certain threshold as I shown below. So I suggest you to focus on ROI segmentation properly, if this is done, the rest is quite easy.
rgbImage=imread('image_preeti.jpeg');
grayImage=rgb2gray(rgbImage);
th=0.05; %Adjust the threshold accordingly
% Or See other robust image segmentation approaches
bwImage=imbinarize(histeq(grayImage),0.05);
You may need to modify the next line as needed.
frame_data=bwareafilt(bwImage & ~bwareafilt(bwImage,1),2);
[r,c]=find(frame_data==1);
diff_c=max(c)-min(c);
diff_r=max(r)-min(r);
figure,imshow(rgbImage);
rectangle('position', [min(c)-diff_c,min(r),2*diff_c,min(r)+diff_r], 'edgecolor', [1 0 0]);
Futher get the length and windth data, use the following (Simple Maths)
w_data=[min(r),max(r)];
l_data=[min(c),max(c)];
You may have to modify the code as per movement of the legs, whether the left or right leg is forward. Please be sure that, if you try it more or other options, you may get more accurate results. Rearding loop, there are many answers available to perform image call and operation one after the other.
Good Wishes!
Kalyan :)
  4 Comments
preeti verma
preeti verma on 8 Feb 2021
frame_data=bwareafilt(bwImage & ~bwareafilt(bwImage,1),2);
What is the mean by this line can you explain ?
KALYAN ACHARJYA
KALYAN ACHARJYA on 8 Feb 2021
@preeti verma I have used that logic to get the desired results
Here
bwareafilt(bwImage,1)
% Return the 1 highest blob (white part) only
%Rest part is self explanatory ~invert image, & or Operation
You can break the line into multiple lines to understand clearly.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!