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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!