<div id="RTEContent">Hi Mariusz<br> u write :<br> (...)<br> reader->Update();<br> (...)<br> InputImageType::Pointer image = InputImageType::New(); <br> InputImageType::IndexType index; <br> <br> index[0]=1;<br> index[1]=1; <br> <br> signed short pixel_value; <br> <br> /***********************************************<br> Here , your variable image is not yet initialized with something, so it's normal that program crash<br> i think u should add a line like this :<br> **********************************************/<br> image=reader->GetOuput();<br> //then get the pixel value<br> pixel_value= image->GetPixel( index ); <-her program crash<br> cout<<"pixel_value : "<<<br> (...)<br> <br> hope this resolve your problem<br> Let us know what happen,<br> Amir,<br><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;"> Hi Amir<br><br>I did read
ItkSoftwareGuide.pdf and try to do as you can see very similar to this, but still don't know whot's wrong when I try do someting like this:<br><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>(...)<br>reader->Update();<br>(...)<br>InputImageType::Pointer image = InputImageType::New(); <br>InputImageType::IndexType index; <br><br>index[0]=1;<br>index[1]=1; <br><br>signed short pixel_value; <br>pixel_value= image->GetPixel( indexa ); <-her program crash<br>cout<<"pixel_value : "<<pixel_value =""><<endl ;=""><br>(...)<br><br>Can anyone sugest whot I did wrong.<br>Thanks Mariusz.<br><br><br><br>Hi Mariusz,<br>download the ItkSoftwareGuide.pdf from this link
http://www.itk.org/ItkSoftwareGuide.pdf<br>then go to section 4.1.3 Accessing Pixel Data 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><br>mariusz_smch@poczta.fm a écrit :<br><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(caller);<br>//vtkRenderWindowInteractor* renderWindowInteractor=reinterpret_cast(caller);<br>//vtkImageViewer* viewer=reinterpret_cast(caller);<br>int x,y;<br>renderWindowInteractor->GetEventPosition (x, y);<br>float level=viewer->GetColorLevel();<br>cout<<"Level: "<<<" ";<br>float color_window=viewer->GetColorWindow();<br>cout<<"ColorWindow: "<<<" ";<br>cout<<" x: "<<<" y: "<<<br>typedef itk::Image InputImageType;<br>InputImageType::IndexType index;
<br>index[0]=x;<br>index[1]=y;<br>cout<<" Index x: "<<<" y: "<<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 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:"<<<br>std::cerr<<"Color window:"<<<br>renderWindowInteractor->Disable <br>renderWindowInteractor->Delete();<br>viewer->Delete();<br>};<br><br>Thanks for help<br>Mariusz.<br><br><br>----------------------------------------------------------------------<br>Najnowsze informacje... >>> http://link.interia.pl/f18f7<br>_______________________________________________<br>Insight-users mailing list<br>Insight-users@itk.org<br>http://www.itk.org/mailman/listinfo/insight-users<br></endl></pixel_value></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.