How to horizontally extract some region from an image

2 ビュー (過去 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.
  1 件のコメント
sana3 sal
sana3 sal 2018 年 5 月 1 日
Thank youuuu! that was very helpful :D

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMRI についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by