Hi, my name´s Javier González. I&#39;m trying to select one o more regions into an 2D image to make some operations with their pixels. Now I&#39;m using the contour widget, but I don&#39;t know how put the imagen and obtain the information.<br>
<br>My firt code is <br><br>vtkMFCWindow *pvtkMFCWindow;<br>&nbsp;&nbsp;&nbsp; vtkRenderer *pvtkRenderer;<br>&nbsp;&nbsp;&nbsp; vtkActor2D *pvtkActor2D;<br>&nbsp;&nbsp;&nbsp; vtkTextMapper *pvtkTextMapper;<br>&nbsp;&nbsp;&nbsp; vtkImageMapper *pvtkImageMapper;<br>&nbsp;&nbsp;&nbsp; ConnectorType::Pointer connector;<br>
<br>this-&gt;connector-&gt;SetInput( InputImage );<br>&nbsp;&nbsp;&nbsp; this-&gt;connector-&gt;Update(); <br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkImageMapper-&gt;SetInput(this-&gt;connector-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkImageMapper-&gt;SetColorWindow(1000);<br>
&nbsp;&nbsp;&nbsp; this-&gt;pvtkImageMapper-&gt;SetColorLevel(500);<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkActor2D-&gt;SetPosition(this-&gt;coorX,this-&gt;coorY);<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkActor2D-&gt;SetMapper(this-&gt;pvtkImageMapper);<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkRenderer-&gt;AddActor(this-&gt;pvtkActor2D);<br>
&nbsp;&nbsp;&nbsp; this-&gt;pvtkRenderer-&gt;ResetCamera();<br><br>this-&gt;pvtkMFCWindow = new vtkMFCWindow(nID);<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkMFCWindow-&gt;GetRenderWindow()-&gt;AddRenderer(this-&gt;pvtkRenderer);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
&nbsp;&nbsp;&nbsp; iren-&gt;SetRenderWindow( this-&gt;pvtkMFCWindow-&gt;GetRenderWindow() );<br><br>&nbsp;&nbsp;&nbsp; vtkContourWidget *contourWidget = vtkContourWidget::New();<br>&nbsp;&nbsp;&nbsp; contourWidget-&gt;SetInteractor( iren );<br><br>&nbsp;&nbsp;&nbsp; vtkOrientedGlyphContourRepresentation *rep = vtkOrientedGlyphContourRepresentation::New();<br>
&nbsp;&nbsp;&nbsp; contourWidget-&gt;SetRepresentation( rep );<br>&nbsp;&nbsp;&nbsp; rep-&gt;GetLinesProperty()-&gt;SetColor(1, 0.2, 0);<br>&nbsp;&nbsp;&nbsp; rep-&gt;GetProperty()-&gt;SetColor(0, 0.2, 1);<br>&nbsp;&nbsp;&nbsp; rep-&gt;GetLinesProperty()-&gt;SetLineWidth( 3 );<br>
<br>&nbsp;&nbsp;&nbsp; contourWidget-&gt;On();<br><br>&nbsp;&nbsp;&nbsp; vtkPolyData * pd = vtkPolyData::New();<br><br>&nbsp;&nbsp;&nbsp; vtkPoints&nbsp;&nbsp;&nbsp; *points&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = vtkPoints::New();<br>&nbsp;&nbsp;&nbsp; vtkCellArray *lines&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = vtkCellArray::New();<br>&nbsp;&nbsp;&nbsp; vtkIdType&nbsp;&nbsp;&nbsp; *lineIndices = new vtkIdType[21];<br>
&nbsp;&nbsp;&nbsp; for (int i = 0; i&lt; 20; i++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; const double angle = 2.0*vtkMath::Pi()*i/20.0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; points-&gt;InsertPoint(static_cast&lt;vtkIdType&gt;(i), 0.1*cos(angle),<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0.1*sin(angle), 0.0 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lineIndices[i] = static_cast&lt;vtkIdType&gt;(i);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; lineIndices[20] = 0;<br>&nbsp;&nbsp;&nbsp; lines-&gt;InsertNextCell(21,lineIndices);<br>&nbsp;&nbsp;&nbsp; delete [] lineIndices;<br>&nbsp;&nbsp;&nbsp; pd-&gt;SetPoints(points);<br>
&nbsp;&nbsp;&nbsp; pd-&gt;SetLines(lines);<br>&nbsp;&nbsp;&nbsp; points-&gt;Delete();<br>&nbsp;&nbsp;&nbsp; lines-&gt;Delete();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; contourWidget-&gt;Initialize(pd);<br>&nbsp;&nbsp;&nbsp; contourWidget-&gt;Render();<br><br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkRenderer-&gt;SetBackground(1.0,1.0,1.0);<br>
&nbsp;&nbsp;&nbsp; this-&gt;pvtkRenderer-&gt;AddActor(this-&gt;pvtkActor2D);<br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkRenderer-&gt;ResetCamera();<br><br>&nbsp;&nbsp;&nbsp; this-&gt;pvtkMFCWindow-&gt;GetRenderWindow()-&gt;Render();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; iren-&gt;Initialize();<br>
<br>If I charge the image I lose the contour and I don&#39;t know how obtain the information of the pixel into the contour.<br><br>I&#39;m in the rigth way o should I change the method? Is there ahother widget better to this operation?<br>
<br>Thanks<br>