[vtkusers] why the color of actor is white by seting the vtkLookupTable

朱文武 cool.wenwu at gmail.com
Fri Apr 16 21:49:22 EDT 2010


thanks ,bill! i will try, then tell you the result .

On Sat, Apr 17, 2010 at 3:53 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> Another idea. It seems that one pipeline piece is changing the cell
> data. Try changing the mapper's input to determine which filter is the
> culprit.
>
> Try
> mapper->SetInput(cube->GetOutput());
> first.
>
> Do you get the proper coloring?
>
> bill
>
>
> On Fri, Apr 16, 2010 at 3:39 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
> > Try,
> > smoother->GenerateErrorScalarsOff() ;
> >
> > On Fri, Apr 16, 2010 at 1:30 AM, 朱文武 <cool.wenwu at gmail.com> wrote:
> >> Bill, thanks very much !
> >> Here are the all related codes:
> >> vtkSmartPointer<vtkBMPReader> m_read =
> vtkSmartPointer<vtkBMPReader>::New();
> >> m_read->SetFilePrefix("C:/Data/brain/TCVH_");//
> >> m_read->SetFilePattern("%s%d.bmp"); //
> >> m_read->Allow8BitBMPOn();
> >> m_read->SetDataByteOrderToLittleEndian();
> >> m_read->SetFileNameSliceOffset(5);//
> >> m_read->SetFileNameSliceSpacing(1);//
> >> m_read->SetNumberOfScalarComponents(3);//
> >> m_read->SetDataOrigin(0.0,0.0,0.0);//
> >> m_read->SetDataSpacing(0.167*4,0.167*4,1);//
> >> m_read->SetDataExtent(0,299,0,345,1300,1320);//
> >> m_read->Update();
> >>
> >> vtkSmartPointer<vtkDiscreteMarchingCubes> cube =
> >>     vtkSmartPointer<vtkDiscreteMarchingCubes>::New() ;
> >> cube->SetInput((vtkDataObject*) m_read->GetOutput() );
> >> cube->SetValue(0, 111);
> >> cube->SetValue(1, 121);
> >> cube->Update() ;
> >>
> >> vtkSmartPointer<vtkDecimatePro>  deci =
> >> vtkSmartPointer<vtkDecimatePro>::New();
> >> deci->SetInputConnection(cube->GetOutputPort());//
> >> deci->SetTargetReduction(0.5); //
> >> deci->PreserveTopologyOn(); //
> >> deci->ReleaseDataFlagOn();
> >>
> >> vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother=
> >> vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();
> >> smoother->SetInput(deci->GetOutput());
> >> smoother->SetNumberOfIterations(30) ;
> >> smoother->NonManifoldSmoothingOn();
> >> smoother->NormalizeCoordinatesOn();
> >> smoother->GenerateErrorScalarsOn() ;
> >> smoother->Update();
> >>
> >> vtkSmartPointer<vtkLookupTable> colorLookupTable=
> >> vtkSmartPointer<vtkLookupTable>::New();
> >>
> >> colorLookupTable->SetTableRange(0, 122);
> >> colorLookupTable->SetNumberOfTableValues(123);
> >> colorLookupTable->Build();
> >> for (int i =0; i < 111; i++)
> >> {
> >>     colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0);
> >> }
> >> colorLookupTable->SetTableValue(111, 1,0,0,1);
> >> for (int j = 112; j <120; j++)
> >> {
> >>     colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0);
> >>
> >> }
> >> colorLookupTable->SetTableValue(121, 0,1,1,1);
> >> colorLookupTable->SetTableValue(122, 0,1,1,1);
> >>
> >> vtkSmartPointer<vtkPolyDataNormals> triangleCellNormals =
> >> vtkSmartPointer<vtkPolyDataNormals>::New();
> >> triangleCellNormals->SetInput(smoother->GetOutput());
> >> triangleCellNormals->ComputeCellNormalsOn();
> >> triangleCellNormals->ComputePointNormalsOff();
> >> triangleCellNormals->ConsistencyOn();
> >> triangleCellNormals->AutoOrientNormalsOn();
> >> triangleCellNormals->Update() ;
> >>
> >> vtkSmartPointer<vtkPolyDataMapper> mapper =
> >> vtkSmartPointer<vtkPolyDataMapper>::New();
> >> mapper->SetInput(triangleCellNormals->GetOutput()); // #this is better
> for
> >> vis
> >> mapper->ScalarVisibilityOn() ;//#show colour
> >> mapper->SetScalarRange(colorLookupTable->GetTableRange());
> >> mapper->SetScalarModeToUseCellData() ; //  contains the label eg. 31
> >> //mapper->SetScalarModeToUsePointData() ;//#the smoother error relates
> to
> >> the verts
> >> mapper->SetLookupTable(colorLookupTable);
> >>
> >> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
> >> actor->SetMapper(mapper);
> >>
> >> Waiting for suggestion, thanks in advance !
> >>
> >> Wenwu
> >>
> >>
> >>
> >> On Fri, Apr 16, 2010 at 12:01 PM, Bill Lorensen <
> bill.lorensen at gmail.com>
> >> wrote:
> >>>
> >>> The lookup table and mapper look OK to me. Can you attach the entire
> >>> program if it is not too large?
> >>>
> >>> Bill
> >>>
> >>> On Thu, Apr 15, 2010 at 9:00 PM, 朱文武 <cool.wenwu at gmail.com> wrote:
> >>> > hi all,
> >>> >
> >>> >       I sent the message last night!  However, no one responded ! So,
> i
> >>> > send
> >>> > it again. Please forgive me, if it disrupts you!
> >>> >
> >>> > I use vtkDiscreteMarchingCubes to reconstruct anatomy structure, and
> use
> >>> > the
> >>> > vtkLookupTable to map the color. Now, i design the color map as
> follows:
> >>> > gray value (111) to red,
> >>> > gray value(121) to blue.
> >>> > Other gray value I don't care.
> >>> >
> >>> > Also, the parameter I set in SetValue() of  vtkDiscreteMarchingCubes
> is:
> >>> > SetValue(0, 111);
> >>> > SetValue(1, 121);
> >>> >
> >>> > Then i set the lookup table as follows:
> >>> > vtkSmartPointer<vtkLookupTable> colorLookupTable=
> >>> > vtkSmartPointer<vtkLookupTable>::New();
> >>> > colorLookupTable->SetTableRange(0, 122); //
> >>> > colorLookupTable->SetNumberOfTableValues(123);
> >>> > colorLookupTable->Build();
> >>> >
> >>> > for (int i =0; i < 111; i++)
> >>> > {
> >>> >     colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0); //
> i
> >>> > don't care this loop
> >>> > }
> >>> > colorLookupTable->SetTableValue(111, 1,0,0,1); // this is essential
> for
> >>> > me
> >>> > for (int j = 112; j <120; j++)
> >>> > {
> >>> >     colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0);
> // i
> >>> > don't care this loop
> >>> >
> >>> > }
> >>> > colorLookupTable->SetTableValue(121, 0,0,1,1);
> >>> > colorLookupTable->SetTableValue(122, 0,0,1,1);
> >>> >
> >>> > vtkSmartPointer<vtkPolyDataMapper> mapper =
> >>> > vtkSmartPointer<vtkPolyDataMapper>::New();
> >>> > ...
> >>> > mapper->ScalarVisibilityOn() ;//#show colour
> >>> > mapper->SetScalarRange(colorLookupTable->GetTableRange());
> >>> > mapper->SetScalarModeToUseCellData() ;
> >>> > mapper->SetLookupTable(colorLookupTable);
> >>> >
> >>> > The result of construction is that two structures whose gray value is
> >>> > 111
> >>> > and 121 were reconstructed.
> >>> > However, the color of these actors is the same- white.
> >>> > Ccould anyone tell me why and give some suggestions?
> >>> >
> >>> > Thanks
> >>> > Wenwu
> >>> > _______________________________________________
> >>> > 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
> >>> >
> >>> >
> >>
> >>
> >>
> >> --
> >> 祝
> >> 工作愉快,身体健康!
> >>
> >
>



-- 
祝
工作愉快,身体健康!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100417/9142455b/attachment.htm>


More information about the vtkusers mailing list