Basic Anti-aliasing Filter (Intro to Signals & Systems)
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jonathan Medina
le 1 Fév 2020
Réponse apportée : Image Analyst
le 1 Fév 2020
I am trying to create a function
zaa = antialias(z);
which inputs a hi-res image z and outputs high-res anti-aliased image zaa. The system needs to compute each point of zaa[x,y]:
.The given "high-res" image z is:
z = round(exp(-1/w.^2*((y.'-30).^2+(x-40).^2)));
I am confused on how to implement the Zaa equation into my function. Here's what I have for my function thus far:
function zaa = antialias(z)
zaa = zeros(size(z,1), size(z,2));
for nn = 1:size(z,1) % grabs the number of rows
for mm = 1:size(z,2) % grabs number of columns
if nn > 1 && nn < size(z,1) && mm > 1 && mm < size(z,2)
%zaa(nn,mm) = 1/4 * (z(nn-1,mm)+z(nn+1,mm)+z(nn,mm-1)+z(nn,mm+1));
%zaa(nn,mm) = 1/4 * z(nn-1,nn+1,mm-1,mm+1);
%zaa(nn,mm) = 1/4 * z(nn,mm);
%xx = [nn-1 nn+1 nn nn];
%yy = [mm mm mm-1 mm+1];
%zaa(nn,mm) = 1/4 * z(xx,yy);
end
end
end
end
The commented out section includes my 4 attempts at coding in the difference equation. I'm sure you can tell I am a novice with arrays and MATLAB. I am hoping for some guidence on how to write the function appropriately. Any help would be appreciated.
Thanks!
0 commentaires
Réponse acceptée
Image Analyst
le 1 Fév 2020
Try this:
function zaa = antialias(z)
kernel = 1 + [0,1,0; 1,0,1; 0,1,0]/4;
zaa = conv2(z, kernel, 'same');
Note: Because your kernel is not normalized, and sums to 2, your output image zaa will be, on average, twice as bright as z. To avoid that, do this
function zaa = antialias(z)
kernel = 1 + [0,1,0; 1,0,1; 0,1,0]/4;
kernel = kernel / sum(kernel(:));
zaa = conv2(z, kernel, 'same');
Then the output image will have the same average brightness as the input image.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!