Reducing resolution imagesc by convolution

3 次查看(过去 30 天)
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 个评论
ScottB
ScottB 2024-1-18
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 2024-1-19
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.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2024-1-18
编辑:Matt J 2024-1-18
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 个评论
DGM
DGM 2024-1-19
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 2024-1-19
编辑:Matt J 2024-1-19
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.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2024-1-19
编辑:Walter Roberson 2024-1-19
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')

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by