A grayscale image is represented as a matrix in MATLAB. Each matrix element represents a pixel in the image. An element value represents the intensity of the pixel at that location.
Create a cropped image matrix Icrop using inputs given in the following order:
For example, if your image was:
I = [1 2 3 4 5 6 7 8]
And you called crop_image with inputs
Icrop = crop_image(I, 2, 2, 1, 3)
The output Icrop should be
[6 7 8]
you should mention which is which in this matrix Icrop = crop_image(I, 2, 2, 1, 3)
Thank you Payam. I assume you meant specifying the order of the inputs explicitly. I have updated the description to make it clearer.
Good problem!
Can someone help me to solve this question? I did not learn image processing. So I tried to solve this question assuming that the pixels either have a value of 1 or 0. I am a beginner. This is my second day into coding. I would really love some help. This is my code:
[Ix,Iy]=size(I);
for n = 1:Ix %for Rmin
if I(n,:)==0
n = n + 1;
else n = n;
break
end
end
Rmin = n
for m = 1:Iy %for Cmin
if I(:,m)==0
m = m + 1;
else m = m;
break
end
end
Cmin = m
for o = Rmin:Ix %for Rmax
if I(o,Cmin) == 1
o = o+1;
elseif I(o,Cmin) == 0
o = o - 1;
break;
end
end
Rmax = o
for p = Cmin:Iy %for Cmax
if I(Rmin,p) == 1
p = p+1;
elseif I(Rmin,p) == 0
p = p - 1;
break;
end
end
Cmax = p
Rpix = Rmax - Rmin + 1
Cpix = Cmax - Cmin + 1
Hint please?
8704 Solvers
All your base are belong to us
428 Solvers
270 Solvers
Getting the indices from a matrice
279 Solvers
298 Solvers