Is there Auto image cutting function???

2 次查看(过去 30 天)
Coeing
Coeing 2015-11-13
Hi ~:)
I have a question about functions.
I want to ged rid of black image from below image. (That image is example. Real one is more complecated.) Is there function that I can easily remove black area??
I'm using Matlab version 2013. Plz help me! Thank you!!^^
[example image]
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

回答(2 个)

Thorsten
Thorsten 2015-11-13
编辑:Thorsten 2015-11-13
To crop a 2D image I:
M = (I==I(1,1));
Ic = I(~all(M,2), ~all(M));
This would also remove a black horizontal line that goes right through the white block. If this is not desired and only the borders should be cropped, use:
Ic = I(find(~all(M,2) == 1, 1, 'first'):find(~all(M,2) == 1, 1, 'last'),...
find(~all(M ) == 1, 1, 'first'):find(~all(M ) == 1, 1, 'last'));

Image Analyst
Image Analyst 2015-11-13
See my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 I do that - I find individual blobs/coins in the image and crop each one out.

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by