フィルターのクリア

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

11 ビュー (過去 30 日間)
Gulfam Saju
Gulfam Saju 2022 年 8 月 4 日
編集済み: Image Analyst 2022 年 8 月 4 日
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 Center および File ExchangeGet 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