Image rectangle using matrix - antialiasing
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I'm trying to write a script that draws a rectangle from an array. It remains to solve the problem mainly on the edge antialiasing. Can someone help me? thanks
function linea
Nx = 64;
Ny = 64;
x0 = 32;
y0 = 32;
l = 30;
h = 5;
for theta = 0:0.5:360.5
im = ones(Nx,Ny);
theta = theta * pi / 180;
for i = -l/2:l/2
for j = -h/2:h/2
x = x0 + i * cos(theta) + j * sin(theta);
y = y0 - i * sin(theta) + j * cos(theta);
im(round(x),round(y)) = 0;
end
end
imagesc(im,[0 1]);
axis image
colormap gray
drawnow
end
end
Réponse acceptée
Image Analyst
le 18 Nov 2013
You can blur im with conv2() to smooth out edges. But a bigger problem is the way you send 0's to your output image. Doing that will give you "holes" where no pixel got set. You need to invert that and scan your output array and figure out what 4 pixels in the input it should come from. If you do that you'll not only eliminate holes, but also have smooth edges because you'll be doing bilinear interpolation.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!