Extract 80 by 80 patch from image by taking center point of each object in image.

 Réponse acceptée

% Get the size of the image
[rows, columns, numberOfColorChannels] = size(yourImage);
% Determine starting and ending rows and columns.
row1 = floor(rows/2 - 40);
col1 = floor(columns/2-40);
% Extract sub-image using imcrop():
subImage = imcrop(yourImage, [col1, row1, 80, 80]);

3 commentaires

I want to extract the patch from finding the center of each object and then taking the patch...here is the code..>How to extract patch Now.
L,num] = bwlabel(ImageFilled);
stats=regionprops(L,'Centroid');
for k = 1:numel(stats)
c = stats(k).Centroid;
end
Nearly the same as what I already showed you:
% Determine starting and ending rows and columns.
row1 = floor(c(2) - 40);
col1 = floor(c(1) - 40);
% Extract sub-image using imcrop():
subImage = imcrop(yourImage, [col1, row1, 80, 80]);
Thank you very much....my problem is solved..i spend 4 to 5 hours on this task...and now you can estimate my happiness after the task is done at last...bundle of thanks..

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by