[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Vectorising circle drawing
From: |
soren |
Subject: |
Vectorising circle drawing |
Date: |
Mon, 21 Apr 2008 13:38:57 +0200 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.2-RC1) |
Hi All,
I have a matrix 'cr' where each row contains the center and radius
of a circle. Now, I want to draw these circles in a image. Currently,
I do this by looping over each row, and then I draw the circle. This
is however a bit slow, so I was wondering if I was missing some cool
trick to vectorise this code:
num_circles = rows (data);
[XX, YY] = meshgrid (1:columns (I), 1:rows (I));
for k = 1:num_circles
C = (XX - cr (k, 2)).^2 + (YY - cr (k, 1)).^2 <= cr (k, 3).^2;
mask (C) = 1;
endfor
where 'I' is a matrix of the same size as the matrix 'mask'.
Any thoughts?
Søren
- Vectorising circle drawing,
soren <=