Image rectangle using matrix - antialiasing
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2013년 11월 18일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!