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
-
24 Comments
Show
21 older comments
Rokas
on 26 Sep 2022
Rmin - start keeping image from row
Cmin - start keeping image from column
Rpix - the number of rows to keep starting from Rmin
Cpix - the number of columns to keep starting from Cmin
sky
on 2 Jan 2024
good one..
Ha
on 26 Feb 2024
Problem is interesting to solve.
Solution Comments
Show commentsProblem Recent Solvers7581
Suggested Problems
-
2332 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1198 Solvers
-
Number of 1s in a binary string
9598 Solvers
-
Solve a System of Linear Equations
12658 Solvers
-
11120 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!