MATLAB Answers


Patch extraction from an image

How to extract a number of patches from the image


Sign in to comment.


1 Answer

Answer by pankhuri kasliwal on 18 Jun 2019
 Accepted Answer

if you want a patch of (size, size) :
% Get the size of the image
[rows, columns, numberOfColorChannels] = size(yourImage);
% Determine starting and ending rows and columns.
row1 = floor(rows/2 - size/2);
col1 = floor(columns/2- size/2);
% Extract sub-image using imcrop():
subImage = imcrop(yourImage, [col1, row1, size, size]);
you may also refer to this link for more information

  1 Comment

Thankyou ma'am for your answer.
It was very useful.

Sign in to comment.