필터 지우기
필터 지우기

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 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