How to demonstrate aliasing and sampling phase in imaging

7 views (last 30 days)
Dear all,
I'd like to demonstrate influence of magnification and thus equivalent size of individual pixel in camera plane on image appearance. This topic is closely related to sampling of classic 1D signals with one additional step: sampling in imaging is related to averaging over equivalent pixel area, not just picking a point corresponding to Delta-function. Source: Boreman, "Modulation transfer function in optical and electro-optical systems"
I would like to visualize influence of aliasing (too big equivalent pixel size) and sampling phase using simple function like sin and spatially unlimited image to avoid border effects.
What do I do:
a=sin(pi/2:0.1:5*pi/2); % 'continous' signal
b=repmat(a,512,9);
figure, imshow(b,[])
figure, plot(b(1,:))
%aliasing, sampling rate lower than recommended
alias=blockproc(cat(2,zeros(128,17),b(1:128,:),zeros(128,15)),[1 40],@(x) mean2(x.data));
figure, imshow(alias(1:128,:),[])
figure, plot(alias(1,:))
set(gca,'ylim',[-1 1])
%no aliasing and sampling phase
upsample=blockproc(b(1:128,:),[1 30],@(x) mean2(x.data));
figure, imshow(upsample(1:128,:),[])
figure, plot(upsample(1,:))
set(gca,'ylim',[-1 1])
%no aliasing and maximal sampling phase
norm=blockproc(cat(2,zeros(128,17),b(1:128,:),zeros(128,15)),[1 30],@(x) mean2(x.data));
figure, imshow(norm(1:128,:),[])
figure, plot(norm(1,:))
set(gca,'ylim',[-1 1])
cat_img=cat(1,...
b(1:32,:),...
imresize(alias,[128,size(b,2)],'nearest'),...
b(1:32,:),...
imresize(upsample,[128,size(b,2)],'nearest'),...
b(1:32,:),...
imresize(norm,[128,size(b,2)],'nearest'),...
b(1:32,:));
figure, imshow(cat_img,[])
If you run the code above you see that even at sampling at more than twice higher frequency the sin frequency, I obtain bell-shaped suppressed intensities, probably according to border effects. If I increase image size, I see the "bells" to be periodic.
What am I doing wrong and what should I do?

Answers (1)

Joshua
Joshua on 27 Sep 2022
a=sin(pi/2:0.1:5*pi/2); % 'continous' signal
b=repmat(a,512,9);
figure, imshow(b,[])
figure, plot(b(1,:))
%aliasing, sampling rate lower than recommended
alias=blockproc(cat(2,zeros(128,17),b(1:128,:),zeros(128,15)),[1 40],@(x) mean2(x.data));
figure, imshow(alias(1:128,:),[])
figure, plot(alias(1,:))
set(gca,'ylim',[-1 1])
%no aliasing and sampling phase
upsample=blockproc(b(1:128,:),[1 30],@(x) mean2(x.data));
figure, imshow(upsample(1:128,:),[])
figure, plot(upsample(1,:))
set(gca,'ylim',[-1 1])
%no aliasing and maximal sampling phase
norm=blockproc(cat(2,zeros(128,17),b(1:128,:),zeros(128,15)),[1 30],@(x) mean2(x.data));
figure, imshow(norm(1:128,:),[])
figure, plot(norm(1,:))
set(gca,'ylim',[-1 1])
cat_img=cat(1,...
b(1:32,:),...
imresize(alias,[128,size(b,2)],'nearest'),...
b(1:32,:),...
imresize(upsample,[128,size(b,2)],'nearest'),...
b(1:32,:),...
imresize(norm,[128,size(b,2)],'nearest'),...
b(1:32,:));
figure, imshow(cat_img,[])

Categories

Find more on Axes Appearance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!