Scale up an image without interpolation

7 visualizaciones (últimos 30 días)
Valentin Magidson
Valentin Magidson el 6 de En. de 2016
Comentada: Patryk Trybalski el 7 de Jun. de 2021
I have 3D image, which I need to scale up with integer scaling coefficient (e.g. x3, x5). ImageJ have an interpolation option "None", alongside with "Bilinear" and "Bicubic", but Matlab functions (like resize, imresize) do not include "none" option. It is useful for overlaying high resolution image over original low resolution one. I need to replace each voxel with a volume of identical value pixels. Can I do something smarter then nested FOR loops?

Respuesta aceptada

Image Analyst
Image Analyst el 6 de En. de 2016
The option is not called 'none', it's called 'nearest'. This will basically replicate voxels, not interpolate them. I'm sure your ImageJ is doing it the same way.
bigArray = imresize(smallArray, 3.456, 'nearest');
  2 comentarios
Valentin Magidson
Valentin Magidson el 6 de En. de 2016
Thanks, it works great for 2D images. For 3D it operates on each 2D slice separately, but repmat(Matrix2D,1,1,scale) can expand each slice.
Patryk Trybalski
Patryk Trybalski el 7 de Jun. de 2021
Ain't 'nearset' the nearest neightbor interpolation?

Iniciar sesión para comentar.

Más respuestas (1)

Adam
Adam el 6 de En. de 2016
Editada: Adam el 6 de En. de 2016
Something like this should work I think, with a single for loop. I'm not sure if it could be done without a for loop at all. Probably some combination of repmat and reshape may work to do the whole thing at once rather than a row at a time.
scaleFactor = 3;
inputImage = rand( 3, 4 );
outputImage = zeros( size( inputImage ) * scaleFactor );
nOutputColumns = size( outputImage, 2 );
outputRowIndices = 1:scaleFactor:size( outputImage, 1 );
for i = 1:size( inputImage, 1 )
idx = outputRowIndices(i);
outputImage( idx:idx+2, : ) = reshape( repmat( inputImage(i,:), scaleFactor^2 , 1 ), scaleFactor, nOutputColumns );
end

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by