I have an image of size 61x56 and I want to pad the image to size 392x392.
I am trying to use padarray
but since I get a non-integer value I am unable to do this. Can anyone help me with this. Thanks a lot! I have attached what I want to do below.
K = imread('test.jpg');
K = rgb2gray(K);
[m n] = size(K);
p = 392;
q = 392;
K_pad = padarray(K, [(p-m)/2 (q-n)/2], 'replicate');
You can divide your
padarray
instruction in two calls:But you may want to check what is happening in the corners of the image to see if it is ok with what you want to do with it.
You can try this function:
for example:
first it finds the maximum of rows and columns, then paddarray the matrix in both direction.
Here's another way of padding it without using
padarray
.