<div id="RTEContent">Hi Mariusz,<br> download the <span style="font-weight: bold;">ItkSoftwareGuide.pdf</span> from this link http://www.itk.org/ItkSoftwareGuide.pdf<br> then go to section <span style="font-weight: bold;">4.1.3 Accessing Pixel Data </span>page 38, where you will read about SetPixel() and GetPixel() method, i think that's what u need in that case.<br> you have to do something like this :<br> <br> ImageType::IndexType pixelIndex;<br> <br> pixelIndex[0] = x; // x position of the pixel<br> pixelIndex[1] = y; // y position of the pixel<br> <br> ImageType::PixelType pixelValue = image->GetPixel( pixelIndex );<br> <br> hope that help u.<br> Amir<br style="font-weight: bold;"><br><b><i>mariusz_smch@poczta.fm</i></b> a écrit :<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> <br>Hi all.<br><br>How get pixel value
prom 2D DICOM Slices.<br>I clic on the image and have mouse coordinats from<br>vtkCommand:<br><br>renderWindowInteractor->GetEventPosition (x, y)<br><br>now I woul like to get pixel value but I don't know how. Do I supose to transfer coordinat x,y?<br>Here is peace of my code:<br><br><br>typedef signed short InputPixelType;<br>const unsigned int InputDimension = 2;<br>typedef itk::Image< InputPixelType, InputDimension > InputImageType;<br>InputImageType::Pointer image;//= InputImageType::New();<br>//InputImageType::PixelType pixelValue;<br><br>vtkRenderWindowInteractor* renderWindowInteractor;<br>vtkImageViewer* viewer;<br><br>class vtkMyCallback : public vtkCommand<br>{<br>public:<br> static vtkMyCallback *New() <br> { return new vtkMyCallback; }<br> virtual void Execute(vtkObject *caller, unsigned long, void*)<br> {<br> vtkRenderer *renderer = reinterpret_cast<vtkRenderer *="">(caller);<br> //vtkRenderWindowInteractor*
renderWindowInteractor=reinterpret_cast<vtkRenderWindowInteractor *="">(caller);<br> //vtkImageViewer* viewer=reinterpret_cast<vtkImageViewer *="">(caller);<br> int x,y;<br> renderWindowInteractor->GetEventPosition (x, y);<br> float level=viewer->GetColorLevel();<br> cout<<"Level: "<<level =""><<" ";<br> float color_window=viewer->GetColorWindow();<br> cout<<"ColorWindow: "<<color_window =""><<" ";<br> cout<<" x: "<<x =""><<" y: "<<y ;=""><<endl ;=""><br> typedef itk::Image<signed short="" 2=""> InputImageType;<br> InputImageType::IndexType index; <br> index[0]=x;<br> index[1]=y;<br> cout<<" Index x: "<<index [0=""><<" y: "<<index [1=""><br> signed short pixel_value;<br><br>HERE I don't kow how get the value?<br> pixel_value=image->GetPixel( index );<br> }<br>};<br><br><br>void vtkdisp(const char * out_dirname_c){<br>// typedef signed short InputPixelType;<br>// const unsigned int
InputDimension = 2;<br>// typedef itk::Image< InputPixelType, InputDimension > InputImageType;<br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br> InputImageType::PixelType pixelValue;<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName(out_dirname_c);<br> typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer dicomIO = ImageIOType::New();<br> reader->SetImageIO(dicomIO); //reade mata data <br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject & e)<br> {<br> std::cerr << "exception in file reader " << std::endl;<br> std::cerr << e << std::endl;<br> // return EXIT_FAILURE;<br> } <br> InputImageType::Pointer image = InputImageType::New(); <br> InputImageType::IndexType indexa; <br><br><br> indexa[0]=1;<br> indexa[1]=1;
<<<---do I should transfet thouse coordinat to some others??<br> <br> signed short pixel_value; <br> cout<<"pixel_value---- : "; <br> pixel_value= image->GetPixel( indexa ); <br> <br> typedef itk::ImageToVTKImageFilter<InputImageType> ConnectorType;<br> ConnectorType::Pointer connector= ConnectorType::New();<br> connector->SetInput( reader->GetOutput() ); <br><br> //vtkImageViewer* viewer;<br> viewer= vtkImageViewer::New(); <br> //vtkRenderWindowInteractor* renderWindowInteractor;<br> renderWindowInteractor = vtkRenderWindowInteractor::New(); <br> viewer->SetupInteractor( renderWindowInteractor);<br> viewer->SetInput( connector->GetOutput() );<br> viewer->Render();<br> viewer->SetColorWindow(50);<br> viewer->SetColorLevel(-1000);<br> vtkMyCallback *mo1 = vtkMyCallback::New();<br> renderWindowInteractor->AddObserver(vtkCommand::MouseMoveEvent,mo1);<br> mo1->Delete();<br> <br> renderWindowInteractor->Start(); <br>
float level=viewer->GetColorLevel();<br> float color_window=viewer->GetColorWindow ();<br> std::cerr<<"level:"<<level =""><<endl ;=""><br> std::cerr<<"Color window:"<<color_window =""><<endl ;=""><br> renderWindowInteractor->Disable <br> renderWindowInteractor->Delete();<br> viewer->Delete();<br>};<br><br>Thanks for help<br>Mariusz.<br><br>----------------------------------------------------------------------<br>Najwiekszy czat w Polsce!!! >>> http://link.interia.pl/f18f6<br><br>_______________________________________________<br>Insight-users mailing list<br>Insight-users@itk.org<br>http://www.itk.org/mailman/listinfo/insight-users<br></endl></color_window></endl></level></InputImageType></index></index></signed></endl></y></x></color_window></level></vtkImageViewer></vtkRenderWindowInteractor></vtkRenderer></blockquote><br></div><p>
                <hr size=1> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta.