[Insight-users] How to invert a float image?

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Aug 10 10:13:00 EDT 2009


Hello,

	I too have had trouble using the Invert Image filter. By default it  
just performs:

NumericTraits< TInput >::max() - X

for each pixel element. This definition make sense for unsigned  
integers but is problematic for signed and real numbers. Of course  
there are different interpretations of inversion for these pixel  
types. But for floating and double this will more often then not,  
result in an image full of zeros due to numeric imprecision.

For floats, setting the maximum value to 0, will invert the sign. This  
may be the type of inversion you are talking about.

I would suggest that the filter should be changed so that for real  
types the default should be 0, as the current value results in poor  
outputs more often then not in this case.


On Aug 9, 2009, at 5:50 PM, Gaëtan Lehmann wrote:

>
> Le 9 août 09 à 22:58, lynx.abraxas at freenet.de a écrit :
>
> You have to give the maximum value in your image to
> InvertIntensityImageFilter to have it inversed.
> Dirk has recently proposed to enhance InvertIntensityImageFilter to
> let it compute that value automatically. Maybe he has already
> implemented that feature...

I think we may need 2 different inversion filters:

1) inverts on the values of the range of the image, this would need  
the automatic computation of these values, or the user setting the  
minimum and maximum

Note: the problem with automatically computing the range is that it  
requires the full image and therefor the filter will not be able to  
stream any more

2) inverts on the range of the pixel type, or about zero for reals.  
Again care needs to be take as to not result in overflow.


It is amazing that such an apparent simple filter becomes rather  
complicated when any pixel type can be used. BTW, I just use  
ShiftScale for this type of operation, since it's more logical then  
setting max to zero.


Brad


========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090810/727f92f8/attachment.htm>


More information about the Insight-users mailing list