Crop an Image - MATLAB Cody - MATLAB Central

Problem 44958. Crop an Image

Difficulty:Rate
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:
  1. I - Grayscale input image
  2. Rmin - Lowest row number to retain
  3. Cmin - Lowest column number to retain
  4. Rpix - Number of pixels along rows to retain
  5. Cpix - Number of pixels along columns to retain
&#13
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

38.81% Correct | 61.19% Incorrect
Last Solution submitted on Mar 15, 2025

Problem Comments

Solution Comments

Show comments

Group

MATLAB Onramp Practice Image
MATLAB Onramp Practice
  • 15 Problems
  • 4527 Finishers

Problem Recent Solvers7595

Community Treasure Hunt

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

Start Hunting!
Go to top of page