I'm doing image processing with scipy.ndimage
. Given a ring-shaped object, I'd like to generate a "profile" around its circumference. The profile could be something like thickness measurements at various point around the ring, or the mean signal along the ring's "thickness."
It seems to me that I could use ndimage.mean
if I could first get a good labels image.
If my ring looks like this,
A = array([[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 1, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0]])
I could get the "profile of means" with numpy.mean( A, labels )
where labels
is.
array([[0, 0, 0, 0, 2, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 2, 3, 4, 4, 0, 0],
[0, 0, 1, 1, 2, 3, 4, 5, 0, 0],
[0, 0, 16, 16, 0, 0, 5, 5, 0, 0],
[0, 0, 15, 15, 0, 0, 6, 6, 0, 0],
[0, 0, 14, 14, 0, 0, 7, 7, 0, 0],
[0, 0, 13, 13, 0, 0, 8, 8, 8, 0],
[0, 0, 13, 12, 0, 0, 9, 9, 0, 0],
[0, 0, 12, 12, 11, 10, 9, 9, 0, 0],
[0, 0, 0, 0, 11, 0, 0, 0, 0, 0]])
I bet there's some interpolation stuff that will go overlooked with this, but it's all I can come up with on my own.
Is there a way to generate my proposed labels
image? Is there a better approach for generating my profiles?