[vtkusers] existing filter to perform replace value on vtkImage

Michael Jackson mike.jackson at bluequartz.net
Tue Feb 16 17:35:00 EST 2010


On Feb 16, 2010, at 11:47 AM, David Doria wrote:

> On Tue, Feb 16, 2010 at 1:59 PM, Michael Jackson
> <mike.jackson at bluequartz.net> wrote:
>> Is there an existing filter where I can replace a value in the  
>> image if the
>> value does not meet some criteria? Something like:
>>
>> if (value < 255 ) value = 0;
>>
>> Thanks
>> _________________________________________________________
>> Mike Jackson                  mike.jackson at bluequartz.net
>
> Two things come to mind -
>
> 1) You can identify those regions with vtkImageThreshold:
> http://www.vtk.org/Wiki/VTK/Examples/Images/ImageThreshold
> http://www.vtk.org/doc/nightly/html/classvtkImageThreshold.html
>
> 2) Maybe you can set all the pixels found in (1) to some specific
> value, and then you can use
> vtkImageMathematics::SetOperationToReplaceCByK to replace that
> specific value with 0 (as your original question suggested you want to
> do).
>
> Hope that helps,
>
> David
>
Thanks. I Took a look at those filters but did not really understand  
what I was supposed to set any to? Basically I have a tiff file that  
was supposed to be either black or white. Turns out there are also  
intermediate values in there probably from some anti-aliasing or  
something. So basically, if the value is NOT 255, replace it with 0. I  
was thinking the Array Calculator but my simple mind couldn't really  
come up with an equation that would give me what I want.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio





More information about the vtkusers mailing list