Problem 44958. Crop an Image
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:
- I - Grayscale input image
- Rmin - Lowest row number to retain
- Cmin - Lowest column number to retain
- Rpix - Number of pixels along rows to retain
- Cpix - Number of pixels along columns to retain

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]
Solution Stats
Problem Comments
-
25 Comments
Show
22 older comments
sky
on 2 Jan 2024
good one..
Ha
on 26 Feb 2024
Problem is interesting to solve.
Rich
2 hours and 40 minutes ago
I got stuck on this one for a long time. Can someone explain why you can't use the imcrop function?
Solution Comments
Show commentsProblem Recent Solvers7586
Suggested Problems
-
Select every other element of a vector
33841 Solvers
-
1680 Solvers
-
652 Solvers
-
Pernicious Anniversary Problem
823 Solvers
-
Find Air Temperature from Cricket Stridulation Rate
872 Solvers
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!