image thumbnail

Crop a sub-window from an image

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

282 Downloads

Updated 30 Nov 2012

View License

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

Cite As

Rui Zhao (2021). Crop a sub-window from an image (https://www.mathworks.com/matlabcentral/fileexchange/39244-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!