Issue
To get a sub-image there is imcrop
function. but I want to crop the sub-image using its centroid
, (x,y)
that was achieved already.
Image = 512x512
Centroid = (x,y) = (178.92, 207.20)
Also, the imcrop
function doesn't get any input as Centroid.
B = imcrop(A, [col, row, width, height];
How to crop the sub-image using its centroid ?
Also, according to the specified size and position of the rectangle that is estimated using the center of (x, y)
), the sub-image is cropped but its output wasn't correct.
Ex:
To calculate the input argument of `imcrop` function, we have:
Diam of Obj = 50 pixel.
then its window = 50x50 pixel.
and so 57/2 = 28 to add and subtract of centroid.
Win_Obj = imcrop(RNod,[c(1)-28, c(2)-28, c(1)+28, c(2)+28]);
Solution
According to your post and also the docs, the function imcrop()
uses a rectangle as second parameter in the form [x_min y_min width height]
, so you just need to change your call of imcrop
to the following form:
% c is the known centroid position
Win_Obj = imcrop(RNod, [c(1)-28 c(2)-28 2*28 2*28]);
This should give you a sub-image with your object in the center.
Answered By - avermaet Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.