I = imread('data1.jpg')
[p3, p4] = size(I);
q1 = 50; % size of the crop box
i3_start = floor((p3-q1)/2); % or round instead of floor; using neither gives warning
i3_stop = i3_start + q1;
i4_start = floor((p4-q1)/2);
i4_stop = i4_start + q1;
I = I(i3_start:i3_stop, i4_start:i4_stop, :);
figure ,imshow(I);
I have run this code and get this error " Index exceeds matrix dimensions.
Error in ==> croptry at 10 I = I(i3_start:i3_stop, i4_start:i4_stop, :);"
Can anybody help me to fix this error? I want to crop image at the center