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

21 Ansichten (letzte 30 Tage)
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, :);

Akzeptierte Antwort

Image Analyst
Image Analyst am 4 Aug. 2022
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 Kommentare
Gulfam Saju
Gulfam Saju am 4 Aug. 2022
Bearbeitet: Gulfam Saju am 4 Aug. 2022
Use absolute value to see the image. This one has different dimension 320*320.
Image Analyst
Image Analyst am 4 Aug. 2022
Bearbeitet: Image Analyst am 4 Aug. 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:
However you only put one 2-D image into the .mat file, not a 3-D image.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Display Image finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by