<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">Hi Everyone,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">I'm using vtkPicker to pick cells on an image and draw on the image. I've copied a short version of my program. I'm using vtkDotNet and managedItk. I want to draw lines through the picked points on a 2d tif image. Key 'p' is used to pick a point. The lines need to remain in the same place they've been drawn no matter zooming or rotating. The problem is :<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">1- When I zoom the image and get the picked cell dimension, Z would be a value rather than 0 which I don't understand why.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">2- When I rotate the image and pick the points and draw lines. It seems they are in the right place but when I rotate the image the lines would be somewhere outside the image. <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">I'm using picker.GetPickPosition() to get the dimension of the picked point. I'd probably need to change this. Does anyone know how I can fix the problem? Any suggestions would be a great help<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"> <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">Thanks<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB">Shaadi<o:p></o:p></SPAN></P></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>using</FONT></FONT><FONT size=2> System;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Collections.Generic;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.ComponentModel;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Data;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Drawing;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Linq;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Text;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Windows.Forms;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> System.Collections;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> vtk;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2> itk;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>namespace</FONT></FONT><FONT size=2> InteractiveHierarchicalSegmentationDotNet.Test</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>partial</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>class</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>testPicking</FONT></FONT><FONT size=2> : </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Form</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkCellPicker</FONT></FONT><FONT size=2> picker;</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkRenderer</FONT></FONT><FONT size=2> renderer = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkRenderer</FONT></FONT><FONT size=2>();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> testPicking()</P>
<P>{</P>
<P>InitializeComponent();</P>
<P>vtkFormsWindowControl1.GetRenderWindow().AddRenderer(renderer);</P>
<P>viewImage();</P>
<P>picker = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkCellPicker</FONT></FONT><FONT size=2>();</P>
<P>picker.PickFromListOn(); </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// to make sure picker won't pick props instead of cells</P></FONT></FONT><FONT size=2>
<P>picker.AddObserver((</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>uint</FONT></FONT><FONT size=2>)vtk.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>EventIds</FONT></FONT><FONT size=2>.EndPickEvent, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> vtk.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkDotNetCallback</FONT></FONT><FONT size=2>(annotatePick));</P>
<P>vtkFormsWindowControl1.GetInteractor().SetPicker(picker);</P>
<P></P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> annotatePick(vtk.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkObject</FONT></FONT><FONT size=2> caller, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>uint</FONT></FONT><FONT size=2> eventId,</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>object</FONT></FONT><FONT size=2> clientData, </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>IntPtr</FONT></FONT><FONT size=2> callData)</P>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkActor2D</FONT></FONT><FONT size=2> textActor = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkActor2D</FONT></FONT><FONT size=2>();</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] selPt = picker.GetSelectionPoint();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> x = selPt[0];</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> y = selPt[1];</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] pickPos = picker.GetPickPosition();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> xp = pickPos[0];</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> yp = pickPos[1];</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> zp = pickPos[2];</P>
<P>pointsDataGridView.Rows.Add();</P>
<P>pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[0].Value = xp;</P>
<P>pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[1].Value = yp;</P>
<P>pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[2].Value = zp;</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] newPoint = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] { xp, yp, zp };</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] previousPoint = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[3];</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (pointsDataGridView.Rows.Count == 1)</P>
<P>{</P></FONT><FONT size=2>
<P>previousPoint = newPoint;</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>else</P></FONT></FONT><FONT size=2>
<P>{</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// retrieve the previous row</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> pxp = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Convert</FONT></FONT><FONT size=2>.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[0].Value);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> pyp = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Convert</FONT></FONT><FONT size=2>.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[1].Value);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> pzp = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Convert</FONT></FONT><FONT size=2>.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[2].Value);</P>
<P>previousPoint[0] = pxp;</P>
<P>previousPoint[1] = pyp;</P>
<P>previousPoint[2] = pzp;</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> r = 1, g = 0, b = 0;</P>
<P>createLine(previousPoint, newPoint);</P>
<P>vtkFormsWindowControl1.Refresh();</P>
<P>}</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> createLine(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] startPoint, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>[] endPoint)</P>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkPoints</FONT></FONT><FONT size=2> VTKpoints = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkPoints</FONT></FONT><FONT size=2>();</P>
<P>VTKpoints.SetNumberOfPoints(2);</P></FONT><FONT size=2>
<P>VTKpoints.InsertPoint(0, startPoint[0], startPoint[1], startPoint[2]);</P>
<P>VTKpoints.InsertPoint(1, endPoint[0], endPoint[1], endPoint[2]);</P>
<P> </P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkLine</FONT></FONT><FONT size=2> line = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkLine</FONT></FONT><FONT size=2>();</P>
<P>line.GetPointIds().SetId(0, 0);</P>
<P>line.GetPointIds().SetId(1, 1);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkUnstructuredGrid</FONT></FONT><FONT size=2> grid = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkUnstructuredGrid</FONT></FONT><FONT size=2>();</P>
<P>grid.Allocate(1, 1);</P>
<P>grid.InsertNextCell(line.GetCellType(), line.GetPointIds());</P>
<P>grid.SetPoints(VTKpoints);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkDataSetMapper</FONT></FONT><FONT size=2> aLineMapper = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkDataSetMapper</FONT></FONT><FONT size=2>();</P>
<P>aLineMapper.SetInput(grid);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkActor</FONT></FONT><FONT size=2> aLineActor = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkActor</FONT></FONT><FONT size=2>();</P>
<P>aLineActor.SetMapper(aLineMapper);</P>
<P>aLineActor.AddPosition(0, 0, 0);</P>
<P>aLineActor.GetProperty().SetDiffuseColor(1, 0, 0);</P>
<P>renderer.AddActor(aLineActor);</P>
<P>vtkFormsWindowControl1.GetRenderWindow().AddRenderer(renderer);</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> viewImage()</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>try</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImage_UC3</FONT></FONT><FONT size=2> input = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImage_UC3</FONT></FONT><FONT size=2>.New();</P>
<P>input.Read(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"C:/brain.tif"</FONT></FONT><FONT size=2>);</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Import ITK image to VTK</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImageToVTKImageFilter_IUC3</FONT></FONT><FONT size=2> itk2vtk =</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImageToVTKImageFilter_IUC3</FONT></FONT><FONT size=2>.New();</P>
<P>itk2vtk.SetInput(input);</P>
<P>itk2vtk.Update();</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageData</FONT></FONT><FONT size=2> data = itk2vtk.GetOutput();</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageFlip</FONT></FONT><FONT size=2> imageFlip = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageFlip</FONT></FONT><FONT size=2>();</P>
<P>imageFlip.SetFilteredAxis(1);</P>
<P>imageFlip.SetInput(data);</P>
<P>vtk.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageActor</FONT></FONT><FONT size=2> imageActor = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageActor</FONT></FONT><FONT size=2>();</P>
<P>imageActor.SetInput(imageFlip.GetOutput());</P>
<P>renderer.AddActor(imageActor);</P>
<P>vtkFormsWindowControl1.Update();</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>catch</FONT></FONT><FONT size=2> (</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Exception</FONT></FONT><FONT size=2> ex)</P>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Console</FONT></FONT><FONT size=2>.WriteLine(ex);</P>
<P>}</P>
<P>}</P>
<P>}</P>
<P>}</P></FONT></DIV></div><br>
</body></html>