How to crop/mask image using matlab ?

조회 수: 28 (최근 30일)
Armylia Dewi
Armylia Dewi 2022년 6월 15일
답변: Image Analyst 2022년 7월 9일
how to do cropping on an image ?
  댓글 수: 5
Armylia Dewi
Armylia Dewi 2022년 6월 15일
Yes, like that.
here's an example
Armylia Dewi
Armylia Dewi 2022년 6월 15일
just focus on the part chest- x ray

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

채택된 답변

T.Nikhil kumar
T.Nikhil kumar 2022년 7월 9일
Hey Armylia !
I understand that you want to crop one of the chest x-rays from the bigger image.
I suggest you to try using imcrop function for the purpose
Also, MATLAB has an interactive crop image tool which helps you decide the boundaries for your cropped image interactively using mouse
When the Crop Image tool is active in a figure, the pointer changes to cross hairs when you move it over the target image. Using the mouse, you specify the crop rectangle by clicking and dragging the mouse. You can move or resize the crop rectangle using the mouse. When you are finished sizing and positioning the crop rectangle, create the cropped image by double-clicking the left mouse button. You can also choose Crop Image from the context menu. The figure illustrates the Crop Image tool with the context menu displayed.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 7월 9일
See my attached lung segmentation demo.
It should be easy for you to adapt even though your images are in a different orientation.
Once you have the mask, you can crop your image to the bounding box of just the lungs like this
[r, c] = find(mask);
row1 = min(r);
row2 = max(r);
col1 = min(c);
col2 = max(c);
croppedImage = maskedImage(row1:row2, col1:col2);

카테고리

Help CenterFile Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by