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
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@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 "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
A much better way came to my mind: import numpy as np import pylab from skimage.draw import circle_perimeter img = np.zeros((41, 41)) center_r = center_c = 20 rr, cc = circle_perimeter(center_r, center_c, 18) t = np.arctan2(rr  center_r, cc  center_c) t_sorted = np.argsort(t) rr = rr[t_sorted] cc = cc[t_sorted] img[rr[::4], cc[::4]] = 1 pylab.imshow(img, interpolation='nearest') pylab.show() Johannes Schönberger Am 28.05.2013 um 22:40 schrieb Johannes Schönberger <jschoenberger@demuc.de>:
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@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 "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
 You received this message because you are subscribed to the Google Groups "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
participants (2)

Dan Farmer

Johannes Schönberger