image thumbnail

Crop a sub-window from an image

version (1.38 KB) by Rui Zhao
Solve the problem of build-in imcrop function when the rectangle location exceeds the boundary.


Updated 30 Nov 2012

View License

% solve the boundary problem when cropping RECT in IM
% RES = subwin(IM, RECT)
% IM: input image
% RECT: specific rectangle with coordinates (x, y, w, h)
% RES: cropped subwindow
% im = imread('test.png');
% imshow(subwin(im, [-10, -10, 100, 100]));

Cite As

Rui Zhao (2022). Crop a sub-window from an image (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!