[vtk-developers] Getting Pixel Value from dicom

Angiak tferreira018 at live.com.pt
Wed Dec 14 11:36:35 EST 2011


I'm a complete newbie in vtk and dicon images.
this is my first time using this tool

this is the code i made trying to get the pixel value, but dont work, i
already try diferent codes that are on this site and other ones, but no one
seems to work

what i need to do is read the DICOM file, that i already do.
but now i need to manipulate each pixel of the image, so i want to put it in
a 2Dmatrix.

 vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
	reader->SetFileName("Data\\I000000093665.dcm");
	reader->Update();



  vtkImageData *f = reader->GetOutput();


    int l = reader->GetHeight();
    int c = reader->GetWidth();

    double *m=(double*)malloc(3*sizeof(double));
    int nVolIdx;
    unsigned char *pVtkPix = (unsigned char *)f->GetScalarPointer();
    unsigned short usPix;
	
	int i,j;

	int **matrix=(int**)malloc(l*sizeof(int*));

	for (i=0; i<l; i++)
		matrix[i]=(int*)malloc(c*sizeof(int));

    for (i=0; i<512; i++){
        for (j=0; j<512; j++){
            m[0]=i;
            m[1]=j;
	    m[2]=0;
            nVolIdx = f->FindPoint(m);
            usPix = pVtkPix[nVolIdx];
            matrix[i][j]=usPix;
	  //cout<<matrix[i][j]<<endl;
        }
	}



can anybody help me please
or at least give me some link where the code actually work

Thank you for your time
and sorry about my bad english



--
View this message in context: http://vtk.1045678.n5.nabble.com/Getting-Pixel-Value-from-dicom-tp5074987p5074987.html
Sent from the VTK - Dev mailing list archive at Nabble.com.



More information about the vtk-developers mailing list