简体   繁体   中英

Crop an image in Matlab

I want to crop an image from a specific row onwards. Please help me how can I do this. I am a beginner in Matlab.

This page has a lot of great info on dealing with images in matlab.

When you load an image in matlab, it is loaded as a MxNx3 matrix. The third dimension stores the RGB values of each pixel. So to crop an image you simply select just the range of rows and columns you want to keep:

cropped_image = image(RowStart:RowEnd,ColStart:ColEnd,:);

You can use imcrop function in Matlab CropIm = imcrop(I, rectangle); rectangle is a four-element position vector [xmin ymin width height] which indicates the size and position of the crop rectangle.

Im = imread('test.tif');
Im2 = imcrop(Im,[75 68 130 112]);
imshow(Im), figure, imshow(Im2)

See this: http://www.mathworks.com/help/techdoc/creating_plots/f9-47085.html

There is a graph editor icon in the screen where you see your graph, it should look like this: 扩展图形编辑器按钮

Press it, you will get a big graph editor, now try pressing on the graph or one of the functions, in the lower right part you can set ranges, this will crop the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM