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.<br>
<br>My firt code is <br><br>vtkMFCWindow *pvtkMFCWindow;<br> vtkRenderer *pvtkRenderer;<br> vtkActor2D *pvtkActor2D;<br> vtkTextMapper *pvtkTextMapper;<br> vtkImageMapper *pvtkImageMapper;<br> ConnectorType::Pointer connector;<br>
<br>this->connector->SetInput( InputImage );<br> this->connector->Update(); <br> this->pvtkImageMapper->SetInput(this->connector->GetOutput());<br> this->pvtkImageMapper->SetColorWindow(1000);<br>
this->pvtkImageMapper->SetColorLevel(500);<br> this->pvtkActor2D->SetPosition(this->coorX,this->coorY);<br> this->pvtkActor2D->SetMapper(this->pvtkImageMapper);<br> this->pvtkRenderer->AddActor(this->pvtkActor2D);<br>
this->pvtkRenderer->ResetCamera();<br><br>this->pvtkMFCWindow = new vtkMFCWindow(nID);<br> this->pvtkMFCWindow->GetRenderWindow()->AddRenderer(this->pvtkRenderer);<br> <br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow( this->pvtkMFCWindow->GetRenderWindow() );<br><br> vtkContourWidget *contourWidget = vtkContourWidget::New();<br> contourWidget->SetInteractor( iren );<br><br> vtkOrientedGlyphContourRepresentation *rep = vtkOrientedGlyphContourRepresentation::New();<br>
contourWidget->SetRepresentation( rep );<br> rep->GetLinesProperty()->SetColor(1, 0.2, 0);<br> rep->GetProperty()->SetColor(0, 0.2, 1);<br> rep->GetLinesProperty()->SetLineWidth( 3 );<br>
<br> contourWidget->On();<br><br> vtkPolyData * pd = vtkPolyData::New();<br><br> vtkPoints *points = vtkPoints::New();<br> vtkCellArray *lines = vtkCellArray::New();<br> vtkIdType *lineIndices = new vtkIdType[21];<br>
for (int i = 0; i< 20; i++)<br> {<br> const double angle = 2.0*vtkMath::Pi()*i/20.0;<br> points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),<br> 0.1*sin(angle), 0.0 );<br>
lineIndices[i] = static_cast<vtkIdType>(i);<br> }<br> <br> lineIndices[20] = 0;<br> lines->InsertNextCell(21,lineIndices);<br> delete [] lineIndices;<br> pd->SetPoints(points);<br>
pd->SetLines(lines);<br> points->Delete();<br> lines->Delete();<br> <br> contourWidget->Initialize(pd);<br> contourWidget->Render();<br><br> this->pvtkRenderer->SetBackground(1.0,1.0,1.0);<br>
this->pvtkRenderer->AddActor(this->pvtkActor2D);<br> this->pvtkRenderer->ResetCamera();<br><br> this->pvtkMFCWindow->GetRenderWindow()->Render();<br> <br> iren->Initialize();<br>
<br>If I charge the image I lose the contour and I don't know how obtain the information of the pixel into the contour.<br><br>I'm in the rigth way o should I change the method? Is there ahother widget better to this operation?<br>
<br>Thanks<br>