[vtkusers] problem with vtkImageMapToColors

Glauco Silva glauco.silva at cenpra.gov.br
Wed Aug 23 11:19:13 EDT 2006


Hi,

I would like to know what is wrong in my code or if somebody could give me a solution.

I want to blend two images , BackColor and LabelColor (instances of vtkImageMapToColors, see the code below ), but i need erase some parts of LabelColor.
If a put 
> self.BackColorth.GetOutput().SetScalarComponentFromDouble(i, j,self.mapper.GetZSlice(),0,0)                            [I]
before instancializing LabelColor, I manage to erase the parts, but if i put it after LabelColor
> self.BackColorth.GetOutput().SetScalarComponentFromDouble(i, j,self.mapper.GetZSlice(),0,0)                            [II]
 the parts are not erased.

Due to the pipeline structure, I`d imagine positioning this in different parts of the code wouldn`t make difference. I tried to Update objects and so on, but this doesn''t work.

Can someone explain to me why positioning in [II] the code I use to erase part of the image, it is not erased?

Thanks,
Glauco Buzini da Costa Silva

--------------------

def __init__(self, imagedata1, imagedata2):
        
                            ...

        #self.BackColor = self.CreateImageColor(immagedata1,bwLut)
        self.BackColor = vtkImageMapToColors()
        self.BackColor.SetOutputFormatToRGBA()
        self.BackColor.SetInput(imagedata1)       
        self.BackColor.SetLookupTable(bwLut)
        self.BackColor.GetOutput().Update()  

        #self.BackColorth = self.CreateImageColor(imagedata2,bwLut)
        self.BackColorth = vtkImageMapToColors()
        self.BackColorth.SetOutputFormatToRGBA()
        self.BackColorth.SetInput(imagedata2)       
        self.BackColorth.SetLookupTable(bwLut)
        self.BackColorth.GetOutput().Update()
        
       # for i in range(50):
       #    for j in range(50):
       #         self.BackColorth.GetOutput().SetScalarComponentFromDouble(i, j,self.mapper.GetZSlice(),0,0)                 [I]
         
        #LabelColor = self.CreateImageColor(self.BackColorth.GetOutput(),ilut)
        self.LabelColor = vtkImageMapToColors()
        self.LabelColor.SetOutputFormatToRGBA()
        self.LabelColor.SetInput(self.BackColorth.GetOutput())       
        self.LabelColor.SetLookupTable(ilut)
        self.LabelColor.GetOutput().Update()

        for i in range(50):
            for j in range(50):
                self.BackColorth.GetOutput().SetScalarComponentFromDouble(i, j,self.mapper.GetZSlice(),0,0)                 [II]

        imblend = vtkImageBlend()
        self.imblend = imblend 
        imblend.SetInput(0,self.BackColor.GetOutput())
        imblend.SetInput(1,self.LabelColor.GetOutput())
        imblend.SetOpacity(1,0.8)
        imblend.Update()

        mapper = vtkImageMapper()        
        self.mapper = mapper
        mapper.SetInput(imblend.GetOutput())
        mapper.SetColorLevel(40)
        mapper.SetColorWindow(100)
        mapper.SetZSlice(50)        

        imageActor = vtkActor2D()
        imageActor.SetMapper(mapper)
        #imageActor.SetZSlice(0)
        #imageActor.SetColorLevel(127)
        #imageActor.SetColorWindow(300)
        #self.imageActor.SetPosition((2,2))

        ren = vtkRenderer()
        ren.AddActor2D(imageActor)
                            
                            ...
        
       


   def CreateImageColor(imagedata, ilut):
        
        ImageColor = vtkImageMapToColors()
        ImageColor.SetOutputFormatToRGBA()
        ImageColor.SetInput(imdata)       
        ImageColor.SetLookupTable(ilut)
        ImageColor.GetOutput().Update()        

        return ImageColor
...  ###############################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060823/4fb55ee2/attachment.htm>


More information about the vtkusers mailing list