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.
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:
for n = 1:Ix %for Rmin
n = n + 1;
else n = n;
Rmin = n
for m = 1:Iy %for Cmin
m = m + 1;
else m = m;
Cmin = m
for o = Rmin:Ix %for Rmax
if I(o,Cmin) == 1
o = o+1;
elseif I(o,Cmin) == 0
o = o - 1;
Rmax = o
for p = Cmin:Iy %for Cmax
if I(Rmin,p) == 1
p = p+1;
elseif I(Rmin,p) == 0
p = p - 1;
Cmax = p
Rpix = Rmax - Rmin + 1
Cpix = Cmax - Cmin + 1
Hint 1: You need not know or use anything about the value of pixels in this image.
Hint 2: All you have to do is get a subset of a matrix in MATLAB (the matrix, in this case, represents an image).
The problem generates all the input values, so what is the reason I get a "Out of memory. The likely cause is an infinite recursion within the program." error when I simply input:
Icrop = crop_image(I, Rmin, Cmin, Rpix, Cpix)
I suggest to improve problem's statement.
function Icrop = crop_image(I, Rmin, Cmin, Rpix, Cpix)
Icrop = I(Rmin:Rmin+Rpix-1,Cmin:Cmin+Cpix-1);
how did you do it?
@Ryan Charlinski Think of it more like subsetting a matrix given these values and less like cropping an image. The indices for them start at Rmin and Cmin and go up to Rpix and Cpix. Although, careful for MATLAB indexing starting at 1!
The Goldbach Conjecture, Part 2
Counting in Finnish
Make a random, non-repeating vector.
Split a string into chunks of specified length
sum of first 'n' terms
Calculate Amount of Cake Frosting
Calculate a Damped Sinusoid
Solve a System of Linear Equations
Find MPG of Lightest Cars
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office