How to resize an MRI image data keeping the original field of view?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gulfam Saju
le 4 Août 2022
Modifié(e) : Image Analyst
le 4 Août 2022
I have few MRI datasets, where the dimension of the dataset is 320x640x16. First two dimensions are row and column and the last one is Coil dimension. I want to resize the row and column into 256x256x16, keeping the original Field of view. I tried the below code. But it make changes into the field of view and it cut the slices.
new_data = zeros([256,256,16]);
load brain.mat;
new_data(:,:,:) = raw_data(33:288, 193:448, :);
0 commentaires
Réponse acceptée
Image Analyst
le 4 Août 2022
[rows, columns, numberOfSlices] = size(raw_data)
new_data = zeros(256, 256, numberOfSlices, class(raw_data));
for k = 1 : numberOfSlices
thisImage = raw_data(:, :, k);
new_data(:, :, k) = imresize(thisImage, [256, 256]);
end
5 commentaires
Image Analyst
le 4 Août 2022
Modifié(e) : Image Analyst
le 4 Août 2022
Not sure where you got that weird looking image but this works fine
s = load('brain.mat');
raw_data = s.raw;
[rows, columns, numberOfSlices] = size(raw_data)
new_data = zeros(256, 256, numberOfSlices, class(raw_data));
for k = 1 : numberOfSlices
thisImage = raw_data(:, :, k);
subplot(2, 1, 1);
imshow(thisImage, [])
axis('on', 'image');
new_data(:, :, k) = imresize(thisImage, [256, 256]);
subplot(2, 1, 2);
imshow(new_data(:, :, k), [])
axis('on', 'image');
end
The original and resized images are shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1088605/image.png)
However you only put one 2-D image into the .mat file, not a 3-D image.
Plus de réponses (1)
Matthew Pepich
le 4 Août 2022
I was too slow with my answer and @Image Analyst did it better, but here is another option that just samples the image. This works for displaying a thumbnail where interpolation is not important, but "imresize" is preferred if you need accuracy.
% Get your original image
C = imread('landOcean.jpg');
% Produce a scaled down image
scale = 0.10;
x = round( linspace( 1, size(C,1), size(C,1)*scale ) );
y = round( linspace( 1, size(C,2), size(C,2)*scale ) );
C2 = C(x, y, :);
% Display results
figure();
subplot(2,1,1);
image(C);
axis image;
title( sprintf('Size = %d x %d',size(C,[1 2])) )
subplot(2,1,2);
image(C2);
axis image;
title( sprintf('Size = %d x %d (Scaled to %g%%)',size(C2,[1 2]), 100*scale) )
2 commentaires
Matthew Pepich
le 4 Août 2022
Would it still work to use "linspace" to generate even indices? Ignoring the display part of my solution, try just using this to produce your indices:
x = round( linspace( 1, size(raw_data,1), 256 ) );
y = round( linspace( 1, size(raw_data,2), 256 ) );
new_data = raw_data(x, y, :);
Voir également
Catégories
En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!