How to resize an MRI image data keeping the original field of view?

14 次查看(过去 30 天)
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, :);

采纳的回答

Image Analyst
Image Analyst 2022-8-4
First get one of the images then call imresize.
[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 个评论
Gulfam Saju
Gulfam Saju 2022-8-4
编辑:Gulfam Saju 2022-8-4
Use absolute value to see the image. This one has different dimension 320*320.
Image Analyst
Image Analyst 2022-8-4
编辑:Image Analyst 2022-8-4
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:
However you only put one 2-D image into the .mat file, not a 3-D image.

请先登录,再进行评论。

更多回答(1 个)

Matthew Pepich
Matthew Pepich 2022-8-4
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 个评论
Gulfam Saju
Gulfam Saju 2022-8-4
actually, its not an image file. These are complex data types converted into "mat" files from h5 files.
Matthew Pepich
Matthew Pepich 2022-8-4
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, :);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by