How to horizontally extract some region from an image

2 次查看(过去 30 天)
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 中查找有关 MRI 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by