필터 지우기
필터 지우기

Crop out unwanted part from an image.

조회 수: 5 (최근 30일)
Pramod Bhat
Pramod Bhat 2011년 11월 15일
Dear friends, I want to crop out extra part of CT Head image. I mean i want my image should have only required part of the image by removing unwanted black background.
  댓글 수: 1
Sven
Sven 2011년 11월 15일
So you have a single 2D image?
Let's say you want to remove the top and bottom 5 rows and the first 10 columns:
originalIm = rand(512,512);
croppedIm = originalIm(6:end-5, 11:end);
If this *doesn't* answer your question, please realise that you need to make your question more specific.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 15일
Threshold the image so that the "black" background values are assigned 0. Suppose we refer to that result as ImThr . Then
foregroundcol = any(ImThr);
firstforegroundcol = find(foregroundcol, 1);
lastforegroundcol = find(foregroundcol, 1, 'last');
foregroundrow = any(ImThr,2);
firstforegroundrow = find(foregroundrow, 1);
lastforegroundrow = find(foregroundrow, 1, 'last');
And then we can extract the foreground from the frame:
foregroundImg = OriginalImg(firstforegroundrow:lastforegroundrow, firstforegroundcol:lastforegroundcol);
Note that this construction assumes there is no outline or annotations around the image, just image.

Image Analyst
Image Analyst 2011년 11월 15일
It does exactly this with the standard coins image, assuming you can determine foreground and background solely by intensity thresholding.

카테고리

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