Azzera filtri
Azzera filtri

Reducing resolution imagesc by convolution

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
ScottB
ScottB il 18 Gen 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 il 19 Gen 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.

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 18 Gen 2024
Modificato: Matt J il 18 Gen 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 Commenti
DGM
DGM il 19 Gen 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 il 19 Gen 2024
Modificato: Matt J il 19 Gen 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.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 19 Gen 2024
Modificato: Walter Roberson il 19 Gen 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')

Categorie

Scopri di più su Event Functions in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by