필터 지우기
필터 지우기

How to horizontally extract some region from an image

조회 수: 3 (최근 30일)
sana3 sal
sana3 sal 2018년 4월 30일
댓글: sana3 sal 2018년 5월 1일
Hello, i need to extract horizontal region from MRI image shown, to have only the part that located between L4-L5 vertebra. this must be automatically, i mean that when i gave the image to the code; it must strip the upper region (say the 2/3 of the image)
</matlabcentral/answers/uploaded_files/115437/Capture.PNG> exactly like this example which work vertically:

채택된 답변

Wick
Wick 2018년 5월 1일
I'm assuming you're not looking to do some sort of image processing to identify where the cutoff should be. With that, here's a snippet of code to extract the lower 1/3 of an image. You can then use the 'imwrite' code to save it as a new image, or use it as you see fit. This bit of code assumes the image size is unknown and simply grabs the bottom third. If you know the exact dimensions and can hard code the rows, by all means do that.
IM = imread('image.png'); % creates an m x n x 3 variable from the data in the image file
subplot(121); image(IM); axis equal; % draw original image just for comparison
s = fix(2/3*size(IM,1)); % finds the two-thirds index for the row. The 'fix' command makes sure it's an integer
IM_small = IM(s:end,:,:); % take only rows from s to the end, all columns, all 3 pages
imwrite(IM_small,'image_small.png','png'); % if you want to write it
subplot(122); image(IM_small); axis equal; % just a plot to see what you've kept.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biomedical Imaging에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by