Walking circle_perimeter
Johannes Schönberger
jschoenberger at demuc.de
Tue May 28 16:40:05 EDT 2013
This should do the trick…
import numpy as np
import pylab
from skimage.draw import circle_perimeter
img = np.zeros((41, 41))
rr, cc = circle_perimeter(20, 20, 18)
SKIP_SIZE = 3
img[rr, cc] = 5
for i in range(4):
rri = rr[i::4]
cci = cc[i::4]
rri_sorted = np.argsort(rri)
rri = rri[rri_sorted]
cci = cci[rri_sorted]
cci_sorted = np.argsort(cci)
rri = rri[cci_sorted]
cci = cci[cci_sorted]
img[rri[::SKIP_SIZE], cci[::SKIP_SIZE]] = 1
pylab.imshow(img, interpolation='nearest')
pylab.show()
Johannes Schönberger
Am 28.05.2013 um 18:43 schrieb Dan Farmer <dfarmernv at gmail.com>:
> Hi Guys,
>
> I'm trying to subsample the points returned by circle_perimeter and I'm having trouble. Since the points are calculated in octants (and reflected?) it makes walking it somewhat confusing (see below) Does anyone know off hand how I could walk this thing clockwise for example (or produce a sensible subsample of e.g., every other point or every 4th point, etc).
>
> To be a little more concrete:
>
> from skimage.draw import circle_perimeter
>
> rr, cc = circle_perimeter(12, 12, 10)
> im = zeros((40,40))
> im[rr[::4],cc[::4]] = 1
> imshow(im, cmap=cm.gray)
> # returns one quadrant of the circle
>
> Still Googling, but I'd appreciate any help =)
>
> Thanks,
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups "scikit-image" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
More information about the scikit-image
mailing list