[vtkusers] Set ImageData to zero
Dominique Töpfer
dominique at toepfer-web.de
Wed Sep 28 10:02:48 EDT 2011
There are macros like VTK_DOUBLE defined in vtkTypes.h (
http://www.vtk.org/doc/nightly/html/vtkType_8h_source.html ). So you can
check the scalar type using
if(Image->GetScalarType() == VTK_DOUBLE)
// cast to double
Of course, you can also GetScalarTypeAsString() as suggested by Jothy.
HTH
Dominique
On 28.09.2011 15:21, speedy wrote:
> Thanks a lot for your reply Dominique!
> It is much faster indeed to use GetScalarPointer() instead of iterating
> through the pixels. I still have a problem though: My class doesn't know the
> pixeltype of the image beforehand, but I have to cast the pointer to it. How
> can I achieve this? I know there's the method
>
> Image->GetScalarType(),
>
> but it returns an integer value and I don't know how to proceed with it..
>
>
> Dominique Töpfer wrote:
>> Hi,
>>
>> a similar question was discussed here:
>> http://vtk.1045678.n5.nabble.com/Fast-element-access-of-vtkImageData-td4640137.html#none
>>
>> HTH
>> Dominique
>>
>> On 27.09.2011 15:47, speedy wrote:
>>> Sorry if this question actually has a simple answer, but what is the
>>> fastest
>>> way to set every pixel of a vtkImageData to zero (or any other value
>>> fitting
>>> in its pixeltype)?
>>> I've tried vtkImageThreshold, but it doesn't seem to do anything or maybe
>>> I
>>> am using it wrong:
>>>
>>> threshold = vtkSmartPointer<vtkImageThreshold>::New();
>>> threshold->SetInput(Image);
>>> threshold->ReplaceOutOn();
>>> threshold->SetOutValue(Value);
>>> threshold->ThresholdByLower(maximum_image_value);
>>> threshold->Update();
>>>
>>> --
>>> View this message in context:
>>> http://vtk.1045678.n5.nabble.com/Set-ImageData-to-zero-tp4845442p4845442.html
>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>> --
>> Thus spake the master programmer:
>> "After three days without programming, life becomes meaningless."
>>
>> -- The Tao of Programming by Geoffry James
>>
>> Dominique Töpfer, Dipl.-Inform.
>> Institute of Medical Physics
>> University of Erlangen
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Set-ImageData-to-zero-tp4845442p4849109.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
--
Thus spake the master programmer:
"After three days without programming, life becomes meaningless."
-- The Tao of Programming by Geoffry James
Dominique Töpfer, Dipl.-Inform.
Institute of Medical Physics
University of Erlangen
More information about the vtkusers
mailing list