[Insight-users] masked neighborhood operators (convolution) - want smaller output than input
Amy C
mathematical.coffee at gmail.com
Mon Jan 18 02:41:03 EST 2010
Hi,
I'd like to do something like a convolution, but not quite.
I can't explain it too well so here's a picture.
x.x.x.x
.......
x.x.x.x
.......
x.x.x.x
Here my input image is of dimension 5x7, and the 'x' and '.' are voxels of
the input image. (It is really N-dimensional).
Then there's an image of dimension 3x4 (call it the x-image), where
x-image(i,j) is the value of the (i,j)th 'x' in the picture above.
The idea is I want to do a convolution, but only at the voxels marked 'x'.
I know MaskNeighborhoodOperatorImageFilter does this, however I would like
the output image to be the same dimensions as the x-image - smaller than the
input image. So output(i,j) contains the convolution at the (i,j)th 'x'.
I use this for something done in voxel space, so if the physical
space/origin aren't right it doesn't matter.
The additional bits of information are that:
- I know exactly how to orient the 'x' within the input image; they are on a
regular grid starting at (0,0) of the input image, and then placed every h
voxels (of the input image).
- My kernel is separable ( however, can range from 3x3 to ~35x35. I
anticipate the likely sizes will be 3x3 to ~20x20 ) (mine will be usu. 2-
or 3-D)
If I use MaskNeighborhoodOperatorImageFilter, I'd need to create a mask of
the same size as the input image with 1 where the 'x' are, run it, and then
loop through the output image and copy the values (where the mask is 1) back
to my x-image.
I get the feeling that because my 'x' are regularly spaced and my kernel is
separable, I can modify this code to speed up the convolution greatly, but
I'm not sure how to do it.
The part that causes me the most difficulty is how to make my neighborhood
iterator only walk the 'x' of the input image. I could try a
'iterator += spacing', but I'd need to work out when to skip h rows (eg row
1 of the picture above) and when to skip h voxels (eg in row 0 of the
picture above).
Also, in this case, would it be faster to do one ND convolution or N lots of
1D convolutions?
I think I have three options:
- do the convolution on the input image and at the end pick out the values
that match the indices of the 'x's. Disadvantage being that I have to do the
convolution at every voxel whereas I only want the answer every h voxels, so
I waste some computation (?)
- do N lots of 1D convolutions, but I think this is the same as the previous
option because all the intermediate convolutions will need to be done on the
input image (ie at every voxel). I don't save any time by skipping the
non-'x' voxels.
- do one ND convolution, but only at the indices marked 'x'. I need some way
of visiting just the 'x' with my neighborhood iterator.
Does anyone have some advice regarding this? (apologies for the clumsy
explanation)
thanks,
Amy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100118/f3594b25/attachment.htm>
More information about the Insight-users
mailing list