Borrar filtros
Borrar filtros

Reducing resolution imagesc by convolution

3 visualizaciones (últimos 30 días)
Lieke
Lieke el 18 de En. de 2024
Editada: Walter Roberson el 19 de En. de 2024
Hi,
I'm new to matlab. I'm plotting images of measurements that are made with a new high resoluiton detector. To show the advancement in the field I would like to simulate an image that represents the old detector. This detector has 10x as little pixels. I now have a matrix (v) 769x769x100.
I can do the following to reduce the resolution:
imagesc(mean(v(1:10:end, 1:10:end,:),3));
However the image is not very accurate. Is there another way to produce an more accurate image? Maybe by using convolution?
Thank you in advance!
  2 comentarios
ScottB
ScottB el 18 de En. de 2024
Lieke,
Just curious why you can't simply decimate like you have done without taking the mean.
V = imread('peppers.png');
figure;
j = imshow(V)
sz = size(V)
Vdecimated = V(1:10:end, 1:10:end,:);
Vdecimated = imresize(Vdecimated, 10);
figure;
k = imshow(Vdecimated)
Catalytic
Catalytic el 19 de En. de 2024
I would like to simulate an image that represents the old detector. This detector has 10x as little pixels
If the old detector has worse resolution, that its pixels are 10x as large, not 10x as "little". In any case, convolution is not the thing to model this effect. You want to bin all the pixels in 10x10 blocks.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 18 de En. de 2024
Editada: Matt J el 18 de En. de 2024
You could download sepblockfun from the File Exchange,
v=padarray(v,[1,1,0],'replicate','post'); %pad it to 770x770x100
imagesc( sepblockfun(v,[10,10,nan],'mean') );
  3 comentarios
DGM
DGM el 19 de En. de 2024
The padding is needed because the page geometry is 769x769, which is not integer-divisible by the block size, which is 10x10. This issue could either be resolved by discarding the last 69 rows and columns, or it could be resolved by padding one extra row and column.
The use of NaN instructs the function to make the block size span all pages. The block size is then 10x10x100, and the output is 77x77x1. If you wanted each page averaged blockwise independently, you could use [10 10 1], and the output would be 77x77x100.
Matt J
Matt J el 19 de En. de 2024
Editada: Matt J el 19 de En. de 2024
If I understand correctly, using the sepblockfun in this case I'm sepating the 1st two dimentions in 10x10 blocks and its using the mean to do so. What is happening with the 3rd dimention.
Yes, all that is true. And as @DGM said, putting nan in the 3rd dimension simply tells the code to substitute 100 (the array length length in that dimension) in place of the nan. So, you are indeed averaging over 10x10x100 non-overlapping blocks.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 19 de En. de 2024
Editada: Walter Roberson el 19 de En. de 2024
v = imread('peppers.png');
tiledlayout('flow')
nexttile()
imagesc(v);
title('original');
nexttile();
imagesc(v(1:10:end, 1:10:end,:));
title('decimated')
nexttile();
vresize = imresize(v, 0.1);
imagesc(vresize);
title('resize 0.1');
nexttile();
t1 = conv2(double(v(:,:,1)), ones(10,10)/100, 'same');
t2 = conv2(double(v(:,:,2)), ones(10,10)/100, 'same');
t3 = conv2(double(v(:,:,3)), ones(10,10)/100, 'same');
t1d = t1(1:10:end,1:10:end);
t2d = t2(1:10:end,1:10:end);
t3d = t3(1:10:end,1:10:end);
vconv = cat(3,uint8(t1d),uint8(t2d),uint8(t3d));
image(vconv);
title('convolution + decimate')

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by