Image rectangle using matrix - antialiasing
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Giuseppe
am 18 Nov. 2013
Kommentiert: Giuseppe
am 20 Nov. 2013
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
Akzeptierte Antwort
Image Analyst
am 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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!