3D resize image for BIG image size
[MAIN QUESTION]
I try to resize (reduce) the image size for further image processing because I can’t read whole 3D image data (4176*4176*5856) by small memory. Thus I can’t use "imresize3". My another strategy is I can read them separately for all Z and reduce image half in X and Y using "tiffreadVolume" and "imresize". However, it doesn’t give me image value that iterpolated in Z. Do you have any idea for this?
[SUB QUESTION]
By trying to code my own "imresize3", I got some examples and coded below but it seems it gives a different result. I guess it is antialiasing process. Do you know how to do antialiasing for images? Is it just filtering?
clc; clear all; close all;
% LOAD IMAGE
s = load(‘mri’);
mriVolumeOriginal = squeeze(s.D);
sizeO = size(mriVolumeOriginal);
% SHOW IMAGE
figure; subplot(131);
slice(double(mriVolumeOriginal),sizeO(2)/2,sizeO(1)/2,sizeO(3)/2);
shading interp, colormap gray; axis image;
title(‘Original’);
% RESIZE IMAGE
f = 0.5; % RESIZE RATIO
mriVolumeResized = imresize3(mriVolumeOriginal,f);
sizeR = size(mriVolumeResized);
% SHOW RESIZED IMAGE (by imresize3)
subplot(132);
slice(double(mriVolumeResized),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (imresize3)’);
% NEAREST NEIGHBOR INTERPOLATION (NNI)
% DEFINE THE RESAMPLE SIZE
Col = round(sizeO(1)*f);
Row = round(sizeO(2)*f);
Hig = round(sizeO(3)*f);
%FIND THE RATIO OF THE NEW SIZE BY OLD SIZE
rtR = Row/size(mriVolumeOriginal,1);
rtC = Col/size(mriVolumeOriginal,2);
rtH = Hig/size(mriVolumeOriginal,3);
%OBTAIN THE INTERPOLATED POSITIONS
IR = ceil([1:(size(mriVolumeOriginal,1)*rtR)]./(rtR));
IC = ceil([1:(size(mriVolumeOriginal,2)*rtC)]./(rtC));
IH = ceil([1:(size(mriVolumeOriginal,3)*rtH)]./(rtH));
%ROW_WISE INTERPOLATION
B = mriVolumeOriginal(:,IR,:);
%COLUMN-WISE INTERPOLATION
B = B(IC,:,:);
%HEIGHT-WISE INTERPOLATION
B = B(:,:,IH);
% SHOW RESIZED IMAGE (by nearest neighbor interpolation)
subplot(133);
slice(double(B),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (NNI)’);[MAIN QUESTION]
I try to resize (reduce) the image size for further image processing because I can’t read whole 3D image data (4176*4176*5856) by small memory. Thus I can’t use "imresize3". My another strategy is I can read them separately for all Z and reduce image half in X and Y using "tiffreadVolume" and "imresize". However, it doesn’t give me image value that iterpolated in Z. Do you have any idea for this?
[SUB QUESTION]
By trying to code my own "imresize3", I got some examples and coded below but it seems it gives a different result. I guess it is antialiasing process. Do you know how to do antialiasing for images? Is it just filtering?
clc; clear all; close all;
% LOAD IMAGE
s = load(‘mri’);
mriVolumeOriginal = squeeze(s.D);
sizeO = size(mriVolumeOriginal);
% SHOW IMAGE
figure; subplot(131);
slice(double(mriVolumeOriginal),sizeO(2)/2,sizeO(1)/2,sizeO(3)/2);
shading interp, colormap gray; axis image;
title(‘Original’);
% RESIZE IMAGE
f = 0.5; % RESIZE RATIO
mriVolumeResized = imresize3(mriVolumeOriginal,f);
sizeR = size(mriVolumeResized);
% SHOW RESIZED IMAGE (by imresize3)
subplot(132);
slice(double(mriVolumeResized),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (imresize3)’);
% NEAREST NEIGHBOR INTERPOLATION (NNI)
% DEFINE THE RESAMPLE SIZE
Col = round(sizeO(1)*f);
Row = round(sizeO(2)*f);
Hig = round(sizeO(3)*f);
%FIND THE RATIO OF THE NEW SIZE BY OLD SIZE
rtR = Row/size(mriVolumeOriginal,1);
rtC = Col/size(mriVolumeOriginal,2);
rtH = Hig/size(mriVolumeOriginal,3);
%OBTAIN THE INTERPOLATED POSITIONS
IR = ceil([1:(size(mriVolumeOriginal,1)*rtR)]./(rtR));
IC = ceil([1:(size(mriVolumeOriginal,2)*rtC)]./(rtC));
IH = ceil([1:(size(mriVolumeOriginal,3)*rtH)]./(rtH));
%ROW_WISE INTERPOLATION
B = mriVolumeOriginal(:,IR,:);
%COLUMN-WISE INTERPOLATION
B = B(IC,:,:);
%HEIGHT-WISE INTERPOLATION
B = B(:,:,IH);
% SHOW RESIZED IMAGE (by nearest neighbor interpolation)
subplot(133);
slice(double(B),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (NNI)’); [MAIN QUESTION]
I try to resize (reduce) the image size for further image processing because I can’t read whole 3D image data (4176*4176*5856) by small memory. Thus I can’t use "imresize3". My another strategy is I can read them separately for all Z and reduce image half in X and Y using "tiffreadVolume" and "imresize". However, it doesn’t give me image value that iterpolated in Z. Do you have any idea for this?
[SUB QUESTION]
By trying to code my own "imresize3", I got some examples and coded below but it seems it gives a different result. I guess it is antialiasing process. Do you know how to do antialiasing for images? Is it just filtering?
clc; clear all; close all;
% LOAD IMAGE
s = load(‘mri’);
mriVolumeOriginal = squeeze(s.D);
sizeO = size(mriVolumeOriginal);
% SHOW IMAGE
figure; subplot(131);
slice(double(mriVolumeOriginal),sizeO(2)/2,sizeO(1)/2,sizeO(3)/2);
shading interp, colormap gray; axis image;
title(‘Original’);
% RESIZE IMAGE
f = 0.5; % RESIZE RATIO
mriVolumeResized = imresize3(mriVolumeOriginal,f);
sizeR = size(mriVolumeResized);
% SHOW RESIZED IMAGE (by imresize3)
subplot(132);
slice(double(mriVolumeResized),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (imresize3)’);
% NEAREST NEIGHBOR INTERPOLATION (NNI)
% DEFINE THE RESAMPLE SIZE
Col = round(sizeO(1)*f);
Row = round(sizeO(2)*f);
Hig = round(sizeO(3)*f);
%FIND THE RATIO OF THE NEW SIZE BY OLD SIZE
rtR = Row/size(mriVolumeOriginal,1);
rtC = Col/size(mriVolumeOriginal,2);
rtH = Hig/size(mriVolumeOriginal,3);
%OBTAIN THE INTERPOLATED POSITIONS
IR = ceil([1:(size(mriVolumeOriginal,1)*rtR)]./(rtR));
IC = ceil([1:(size(mriVolumeOriginal,2)*rtC)]./(rtC));
IH = ceil([1:(size(mriVolumeOriginal,3)*rtH)]./(rtH));
%ROW_WISE INTERPOLATION
B = mriVolumeOriginal(:,IR,:);
%COLUMN-WISE INTERPOLATION
B = B(IC,:,:);
%HEIGHT-WISE INTERPOLATION
B = B(:,:,IH);
% SHOW RESIZED IMAGE (by nearest neighbor interpolation)
subplot(133);
slice(double(B),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2);
shading interp, colormap gray; axis image;
title(‘Resized (NNI)’); image, image processing, interpolation, antialiasing MATLAB Answers — New Questions