[Insight-users] NaN Pixel Values

Daniel Mace dlm19 at duke.edu
Tue Jan 29 11:57:47 EST 2008


Robert,

Even if ITK would allow it (it may internally, but I think you would 
have issues with writing and reading it), it probably would not be a 
good idea to do it.  Providing memory isn't an issue, the more practical 
solution would be to create an identically sized mask image with 0's and 
1's denoting your criteria.  It's probably more computationally 
efficient to check the state of the mask image and maintain two 
iterators than it is to check if your image value is NaN (even faster if 
you cast your original image and masked image into a VectorImage and use 
a single VectorImageIterator to walk through the values (this is if you 
need to do further processing on the image)).  You can then write the 
masked image out as a separate file, or use ScalarToArrayCastImageFilter 
to construct it as a vector image and write it out.

Cheers,
Dan



Robert Jason Harris wrote:
>
> Hello all,
>
> I used ITK for a project this past summer, and I have since been 
> reviewing what I have done.  It occurred to me that it might be useful 
> to enter NaN values into some pixels of an image after it had been 
> processed by a filtering algorithm that I wrote.  Is this defined in 
> ITK, or will ITK break?  I have been looking for the use of NaN in 
> ITK, and I've found hints but nothing definite.  I'm thinking of 
> something like the following:
>
> ...
> // process image and come up with criterion based
> // on pixel values to determine which to set to NaN and
> // which to keep at their current value
>
> if ( pixel value < some value)
>  image_iterator.SetPixel(NaN)
> else
> //do nothing.
>
>
>
> Thanks for any help you can provide!
>
> Robert Harris
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list