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

feature extractionImage Processing Toolbox

Hello,i want to Extract 80 by 80 patch from image by taking center point of each object in image. This is gray level image.

Best Answer

% 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]);