[vtkusers] Region of Interest
Javier González González-Zabaleta
jgonzabal at gmail.com
Tue Nov 11 07:53:25 EST 2008
Hi, my name´s Javier González. I'm trying to select one o more regions into
an 2D image to make some operations with their pixels. Now I'm using the
contour widget, but I don't know how put the imagen and obtain the
information.
My firt code is
vtkMFCWindow *pvtkMFCWindow;
vtkRenderer *pvtkRenderer;
vtkActor2D *pvtkActor2D;
vtkTextMapper *pvtkTextMapper;
vtkImageMapper *pvtkImageMapper;
ConnectorType::Pointer connector;
this->connector->SetInput( InputImage );
this->connector->Update();
this->pvtkImageMapper->SetInput(this->connector->GetOutput());
this->pvtkImageMapper->SetColorWindow(1000);
this->pvtkImageMapper->SetColorLevel(500);
this->pvtkActor2D->SetPosition(this->coorX,this->coorY);
this->pvtkActor2D->SetMapper(this->pvtkImageMapper);
this->pvtkRenderer->AddActor(this->pvtkActor2D);
this->pvtkRenderer->ResetCamera();
this->pvtkMFCWindow = new vtkMFCWindow(nID);
this->pvtkMFCWindow->GetRenderWindow()->AddRenderer(this->pvtkRenderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow( this->pvtkMFCWindow->GetRenderWindow() );
vtkContourWidget *contourWidget = vtkContourWidget::New();
contourWidget->SetInteractor( iren );
vtkOrientedGlyphContourRepresentation *rep =
vtkOrientedGlyphContourRepresentation::New();
contourWidget->SetRepresentation( rep );
rep->GetLinesProperty()->SetColor(1, 0.2, 0);
rep->GetProperty()->SetColor(0, 0.2, 1);
rep->GetLinesProperty()->SetLineWidth( 3 );
contourWidget->On();
vtkPolyData * pd = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *lines = vtkCellArray::New();
vtkIdType *lineIndices = new vtkIdType[21];
for (int i = 0; i< 20; i++)
{
const double angle = 2.0*vtkMath::Pi()*i/20.0;
points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),
0.1*sin(angle), 0.0 );
lineIndices[i] = static_cast<vtkIdType>(i);
}
lineIndices[20] = 0;
lines->InsertNextCell(21,lineIndices);
delete [] lineIndices;
pd->SetPoints(points);
pd->SetLines(lines);
points->Delete();
lines->Delete();
contourWidget->Initialize(pd);
contourWidget->Render();
this->pvtkRenderer->SetBackground(1.0,1.0,1.0);
this->pvtkRenderer->AddActor(this->pvtkActor2D);
this->pvtkRenderer->ResetCamera();
this->pvtkMFCWindow->GetRenderWindow()->Render();
iren->Initialize();
If I charge the image I lose the contour and I don't know how obtain the
information of the pixel into the contour.
I'm in the rigth way o should I change the method? Is there ahother widget
better to this operation?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081111/303888c6/attachment.htm>
More information about the vtkusers
mailing list