Get voxel intensity

I have a VC++ app that use VTK for visualizing DICOM CBCT and SimpleITK for segmentation (I intend to do segmentation, until now, it doesn’t working :slight_smile: )

When I click on vtkVolume, I am using vtkCellPicker to know the 3d coordinates of the click. My question is, how can I use this point:

vtkCellPicker* pCellPicker = vtkCellPicker::New();
pCellPicker->Pick(nPosition[0], nPosition[1], 0, m_pRenderer);
pCellPicker->GetCellIJK(nCell);
pCellPicker->GetPointIJK(nPoint);

nCell and nPoint has the same values. But how can I use these values to collect seed values for sitk::ConfidenceConnected filter ?

I mean, how can I know if I click on a bone, or a soft tissue ?

Can you provide me some information regarding this domain ? Or, a proper documentation to lead me for solving this …

Thank you for you time and patience.

Flaviu.

I have tried this code:

double* d = static_cast<double*>(m_pDICOMReader->GetOutput()->GetScalarPointer(nCell[0], nCell[1], nCell[2]))

to check the scalar value from the picked point:

TRACE("%d|%d|%d\t%f|%f|%f\n", nCell[0], nCell[1], nCell[2], 
			d[0], d[1], d[2]);

Result: 340|421|36 0.000000|0.000000|0.000000
Why ? As you can see, the picked point has a valid value … why the scalar value is 0 ?

Hello, friend, g’day.

You need do perform an operation called probing:

            // Output the probed value at the picked location.
            vtkDataSet* dataSet = pCellPicker->GetDataSet();
            vtkCellData* cellData = dataSet->GetCellData();
            vtkDataArray* dataArray = cellData->GetScalars();
            if(  dataArray->GetNumberOfComponents() <= 200 ){
                double values[200]; //max of 200 scalar fields is large enough for most applications
                dataArray->GetTuple( cellPicker->GetCellId(), values );
                QString valuesText = "NO VALUES PICKED";
                for( int i = 0; i < dataArray->GetNumberOfComponents(); ++i )
                    if( i == 0)
                        valuesText = QString::number(values[0]);
                    else
                        valuesText = valuesText + "; " + QString::number(values[i]);
                std::cout << "Picked value(s): " << valuesText << std::endl;
            }

all the best,

Paulo

I wrote:

		vtkDataSet* pDataSet = pCellPicker->GetDataSet();
		vtkCellData* pCellData = pDataSet->GetCellData();
		vtkDataArray* pArrData = pCellData->GetScalars();

at this point

vtkDataArray* pArrData = pCellData->GetScalars();

pArrData is NULL … I don’t know why …

Because pCellData->GetScalars() got NULL pointers, then there no scalars pointers there … I have to mention that pCellPicker, pDataSet and pCellData is valid pointers.

In this case there is another way to get the voxel intensity for a giving voxel ?

I have taken PrintSelf from pCellPicker:

Debug: Off
Modified Time: 667353
Reference Count: 1
Registered Events: (none)
Picking from renderer's prop list
Renderer: 00000193DCB07410
Selection Point: (543,152,0)
Pick Position: (228.553,57.0421,138.613)
Path: 00000193DF0392E0
DataSet: 00000193DF3190D0
CompositeDataSet: (none)
FlatBlockIndex: (none)
Mapper: 00000193DAA81740
Tolerance: 1e-06
MapperPosition: (228.553,57.0421,138.613)
MapperNormal: (1,0,0)
PickNormal: (1,0,0)
Texture: (none)    PickTextureData: Off
PointId: 9241087
CellId: 8943521
SubId: 0
PCoords: (1, 0.535222, 0.782796)
PointIJK: (511, 128, 35)
CellIJK: (510, 127, 34)
ClippingPlaneId: -1
PickClippingPlanes: Off
VolumeOpacityIsovalue: 0.05
UseVolumeGradientOpacity: Off

Maybe I got this pCellData as NULL pointer because I am using this vtkCellPicker on a vtkImageData ? Could be the cause ?

I think I have found the solution, I’ll write here for at least two reasons:

  1. Please correct me if I wrong.
  2. If is correct, then someone who need this can find here a possible solution.

short* dResult = (short*)m_pDICOMReader->GetOutput()->GetScalarPointer(nPoint[0], nPoint[1], nPoint[2]);

and

m_pDICOMReader->GetOutput()->GetScalarComponentAsDouble(nPoint[0], nPoint[1], nPoint[2], 0);

The Paulo solution I cannot used due to retrieving NULL pointer at GetScalars() step … I would be curios if my values is the same as Paulo solution …

I guess that GetScalarPointer/GetScalarComponentAsDouble is not the same thing as “probing” … but in my case, this procedure is failing, as I wrote above … I really don’t know why … anyone get through this issue before ?