image processing - im newbie in matlab. so i need help. im try do this coding but have this error -
i = imread('data1.jpg') [p3, p4] = size(i); q1 = 50; % size of 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(i3_start:i3_stop, i4_start:i4_stop, :); figure ,imshow(i);
i have run code , error " index exceeds matrix dimensions.
error in ==> croptry @ 10 = i(i3_start:i3_stop, i4_start:i4_stop, :);"
can me fix error? want crop image @ center
the error due way call functin size
.
if matrix i
in load image tri-dimensional (n x m x k), have call size
way:
[p3, p4, p5] = size(i)
that is, adding additional parameter (in case "p5").
if call size
as:
[p3, p4] = size(i)
p4 set product of second , third dimension of matrix i
updated code
i = imread('pdb_img_1.jpg'); % modified call "size" % [p3, p4] = size(i) [p3, p4, p5] = size(i) % increased size of "crop box" q1 = 150; % size of 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(i3_start:i3_stop, i4_start:i4_stop, :); figure imshow(i)
original image
Comments
Post a Comment