フィルターのクリア

Reducing resolution imagesc by convolution

3 ビュー (過去 30 日間)
Lieke
Lieke 2024 年 1 月 18 日
編集済み: Walter Roberson 2024 年 1 月 19 日
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 Center および File ExchangeEvent Functions についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by