[vtkusers] Image Resampling

Andrew Crozier andrew.crozier at medunigraz.at
Fri Sep 5 05:46:16 EDT 2014


Hi David,

Thanks very much for the feedback. Your code has given some good ideas.

BW,
Andrew

On 04/09/14 17:59, David Gobbi wrote:
> Hi Andrew,
>
> The "masking" part is what makes this especially tricky.  Also, the NN
> interpolator is very specifically a "nearest neighbor" interpolator,
> its code would have to be changed drastically in order for it to
> instead look for the "nearest neighbor that has a value of X or Y".
> It would need a whole new inner loop to perform the search.
>
> I have a class that doesn't do quite what you need, but it might
> provide you with ideas: it is an interpolator specifically written for
> label images.  It models the voxel positions as random variables
> (Gaussian) and, for each voxel in the resampled image, it finds the
> highest-probability label for that voxel.  It does not, however, allow
> you to ignore specific label values.
>
> http://github.com/dgobbi/AIRS/blob/master/ImageRegistration/vtkLabelInterpolator.h
>
>   - David
>
>
> On Thu, Sep 4, 2014 at 7:00 AM, Andrew Crozier
> <andrew.crozier at medunigraz.at> wrote:
>> I and a colleague are working on an image segmentation problem, where we use
>> marching cubes to generate the surface of a segmentation, apply a custom
>> smoothing operation to the surface mesh with numpy in python, then re-render
>> as a vtk image at an arbitrary higher resolution before writing out for the
>> rest of our workflow.
>>
>> The original data set is, however, not simply a binary data set, but both
>> the 'ones' and 'zeros' are further subdivided into integer 'tag' values. We
>> would like to map said tags to the resampled image, but I am trying to
>> figure out the most efficient way to do that in VTK.
>>
>> -----------------
>>
>> Say, for example, we have an image with four 'tags'; 10, 11, 12 and 13. 10
>> and 11 are assigned a zero value for the surface extraction and smoothing,
>> and 12 and 13 are assigned ones. The surface is extracted, smoothed, and
>> resampled image generated, which now also has ones and zeros as values. I
>> would now like to reassign the appropriate tags, such that zeros always
>> become either 10 or 11 and ones become either 12 or 13.
>>
>> Conceptually, I consider this problem as requiring something like a 'masked
>> nearest neighbour' approach, meaning that each zero pixel in the resampled
>> image should be assigned the tag of the spatially closest 10 or 11 pixel in
>> the original image. I say masked nearest neighbour as it seems equivalent to
>> a nearest neighbour interpolation (such as by using vtkImageInterpolator)
>> but where pixels with a 12 or 13 value are ignored.  The equivaltent mapping
>> would of course be done for 'one' pixels in the resampled image, finding the
>> closest in the original with a 12 or 13 value.
>>
>> -----------------
>>
>> I could, or course, implement this algorithm in pure python as part of my
>> script, but I am keen not to do so unless necessary as the resampled data
>> sets can be quite large. I have fairly limited experience using vtk and
>> would appreciate any suggestions or pointers on how to achieve the desired
>> result.
>>
>> Best wishes,
>> Andrew



More information about the vtkusers mailing list