Cody

Problem 44958. Crop an Image

Solution 2985808

Submitted on 24 Sep 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
I = [[magic(8), ones(8,4), magic(8)];[zeros(10,5),magic(10), zeros(10,5)]; [magic(5),zeros(5,10),magic(5)]]; assert(isequal(crop_image(I,9,6,10,10),magic(10)));

Unrecognized function or variable 'Cin'. Error in crop_image (line 2) I(Rmin:(Rmin+Rpix-1), Cin:(Cmin+Cpix-1)); Error in Test1 (line 2) assert(isequal(crop_image(I,9,6,10,10),magic(10)));

2   Fail
I = [[magic(8), ones(8,4), magic(8)];[zeros(10,5),magic(10), zeros(10,5)]; [magic(5),zeros(5,10),magic(5)]]; assert(isequal(crop_image(I,19,1,5,10),[magic(5),zeros(5)]));

Unrecognized function or variable 'Cin'. Error in crop_image (line 2) I(Rmin:(Rmin+Rpix-1), Cin:(Cmin+Cpix-1)); Error in Test2 (line 2) assert(isequal(crop_image(I,19,1,5,10),[magic(5),zeros(5)]));

3   Fail
I = [zeros(10,20);[zeros(10,5),ones(10,10), zeros(10,5)]; zeros(5,20)]; assert(isequal(crop_image(I,11,6,10,10),ones(10)));

Unrecognized function or variable 'Cin'. Error in crop_image (line 2) I(Rmin:(Rmin+Rpix-1), Cin:(Cmin+Cpix-1)); Error in Test3 (line 2) assert(isequal(crop_image(I,11,6,10,10),ones(10)));

4   Fail
I = [1 2 3 4;5 6 7 8]; assert(isequal(crop_image(I,2,2,1,3),[6 7 8]));

Unrecognized function or variable 'Cin'. Error in crop_image (line 2) I(Rmin:(Rmin+Rpix-1), Cin:(Cmin+Cpix-1)); Error in Test4 (line 2) assert(isequal(crop_image(I,2,2,1,3),[6 7 8]));

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!