How to horizontally extract some region from an image
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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:
Réponse acceptée
Wick
le 1 Mai 2018
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MRI dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!