<div dir="ltr"><div>Dear Cary,<br></div><div>take into accoun that the reader for a JPEG image and that for a DICOM image series are not the same. Furthermore, reading them with ITK and VTK differs on how that is done in each library.<br>
<br>For VTK, you may want to have a look at these VTK examples:<br><br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOM">http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOM</a><br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries">http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries</a><br>
<br></div><div>If you want to know the resolution (also called spacing) you may want to call the <br><span style="font-family:courier new,monospace">double* vtkDICOMImageReader::GetPixelSpacing() </span><br>method. Have a look at the vtkDICOMImageReader class reference at this site: <a href="http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html">http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html</a><br>
<br></div><div>In order to read a DICOM series and know its resolution in ITK, this may be of help:<br><a href="http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM">http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM</a><br>
<br></div><div>Ignore the resampling part; just read the input series and ask about its spacing, i.e.<br><pre class=""><span style="font-family:courier new,monospace"><span class="">const</span> InputImageType<span class="">::</span><span class="">SpacingType</span><span class="">&</span> inputSpacing <span class="">=</span>
reader<span class="">-</span><span class="">></span>GetOutput<span class="">(</span><span class="">)</span><span class="">-</span><span class="">></span>GetSpacing<span class="">(</span><span class="">)</span><span class="">;</span></span><br>
<br></pre></div><div><div class="gmail_extra"><div class="gmail_quote"><br>HTH,<br><br>JON HAITZ<br><br><br>On 6 June 2013 02:51, Cary lorey <span dir="ltr"><<a href="mailto:developement.unity@gmail.com" target="_blank">developement.unity@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I am trying to read a DICOM image with itk and visualize it with vtk and see, I tried to get the resolution with itk but there is no method that allows, I recovers just the length and width of the image in pixels.</div>
<div> if you have an idea how to get the resolution of an image can you help me with please</div><div><br></div><div> thank you <span style="font-family:arial,sans-serif;font-size:13px">Nuwan Jayala </span>for the answer but I did not find the method getspacing in itk.</div>
<div><br></div><div> I tried another example of vtkDistanceWidget class, I tried to read a jpg image and I get the measurement between two points millimeter and it works well. but when I changed the type of image on DICOM , the value of the measurement is not correct, I did not understand where the problem is!!!!!</div>
<div><br></div><div>Please can you help me please .here is my code with vtkDistanceWidget (the version that works with jpg is commented):</div><div><br></div><div><div>int main(int, char *[])</div><div>{</div>
<div><span style="white-space:pre-wrap">        </span>/*std::string inputFilename = "C:/nature.jpg";</div><div> </div><div> //Read the image</div><div> vtkSmartPointer<vtkJPEGReader> jpegReader =</div><div>
vtkSmartPointer<vtkJPEGReader>::New();</div><div> jpegReader->SetFileName ( inputFilename.c_str() );*/</div><div><br></div><div><span style="white-space:pre-wrap">        </span>std::string inputFilename = "C:/dicom decompress/dicom decompress/GM_23/2801/0/000121988";</div>
<div> </div><div><span style="white-space:pre-wrap">        </span>LectureFileDicom(inputFilename);</div><div><br></div><div>typedef itk::FlipImageFilter< ImageType > FlipImageFilterType;</div><div><br></div><div>FlipImageFilterType::Pointer flipFilter = FlipImageFilterType::New ();</div>
<div> flipFilter->SetInput( reader->GetOutput() );</div><div> bool flipAxes[3] = { false, true, false };</div><div>flipFilter->SetFlipAxes(flipAxes);</div><div>flipFilter->Update();</div><div><br></div><div>
Connector->SetInput( flipFilter->GetOutput() );</div><div>Connector->Update();</div><div><br></div><div><br></div><div>vtkSmartPointer<vtkImageViewer2> imageViewer =</div><div> vtkSmartPointer<vtkImageViewer2>::New();</div>
<div> // imageViewer->SetInputConnection( jpegReader->GetOutputPort() );</div><div>imageViewer->SetInput(Connector->GetOutput());</div><div><br></div><div> </div><div> // An interactor</div><div> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> imageViewer->SetupInteractor(renderWindowInteractor);</div><div> imageViewer->Render();</div><div> </div><div> vtkSmartPointer<vtkDistanceWidget> distanceWidget =</div>
<div> vtkSmartPointer<vtkDistanceWidget>::New();</div><div> distanceWidget->SetInteractor(renderWindowInteractor);</div><div> // distanceWidget->CreateDefaultRepresentation();</div><div> static_cast<vtkDistanceRepresentation *>(distanceWidget->GetRepresentation())</div>
<div> ->SetLabelFormat("%-#6.3g mm");</div><div> </div><div> // Render an image (lights and cameras are created automatically)</div><div><br></div><div><br></div><div> renderWindowInteractor->Initialize();</div>
<div><br></div><div> distanceWidget->On();</div><div> </div><div> // Begin mouse interaction</div><div> renderWindowInteractor->Start();</div><div> </div><div> return EXIT_SUCCESS;</div><div>}</div></div></div>
<div class=""><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/6/5 Jon Haitz Legarreta <span dir="ltr"><<a href="mailto:jhlegarreta@vicomtech.org" target="_blank">jhlegarreta@vicomtech.org</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div><div><div>Dear Cary,<br></div>ITK will give you the distance in image units, i.e. pixel/voxels. You should ask your image object about its resolution (how many physical distance units each pixel accounts for) and then do the conversion.<br>
<br></div>HTH,<br></div>JON HAITZ<br><div class="gmail_extra"><br clear="all"><div><table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td></td></tr><tr><td><br></td></tr></tbody></table></div><div class="gmail_quote">
<div>
On 4 June 2013 01:35, Cary lorey <span dir="ltr"><<a href="mailto:developement.unity@gmail.com" target="_blank">developement.unity@gmail.com</a>></span> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div>
<div dir="ltr">Hello,<div><br></div><div>I am trying to calculate the distance between 2 points on an image, I modified the code TestDistanceWidget according to my needs, but the problem when I measure the distance between the 2 points, the value is high, then I want a millimeter distance.</div>
<div><br></div><div>Please please can you help me?</div><div><br></div><div>thank you in advance.</div></div>
<br></div></div><div>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></div></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>