计算图像每个角的坐标

时间:2015-02-06 09:15:46

标签: vtk dicom

如何通过渲染器计算图像每个角的坐标?

示例:

double* pBounds = pImageData->GetBounds();
TRACE("%f.%f.%f.%f.%f.%f\n", pBounds[0], pBounds[1], pBounds[2], pBounds[3], pBounds[4], pBounds[5]);

结果:

-228.552734.0.000000.-228.552734.0.000000.0.000000.0.000000

使用vtkCoordinate?但是如何?

1 个答案:

答案 0 :(得分:0)

我想我成功了:

double* pBounds = pImageData->GetBounds();
vtkCoordinate* pCoordinate = vtkCoordinate::New();
pCoordinate->SetValue(0, 0, 0);
pCoordinate->SetValue(pBounds[0], pBounds[2], 0);
int* pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer);
TRACE("BottomLeft:x:%d - y:%d\n", pValueInt[0], pValueInt[1]);
pCoordinate->SetValue(pBounds[1], pBounds[3], 0);
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer);
TRACE("TopRight:x:%d - y:%d\n", pValueInt[0], pValueInt[1]);
pCoordinate->SetValue(pBounds[2], pBounds[4], 0);
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer);
TRACE("TopLeft:x:%d - y:%d\n", pValueInt[0], pValueInt[1]);
pCoordinate->SetValue(pBounds[4], pBounds[2], 0);
pValueInt = pCoordinate->GetComputedDisplayValue(m_pRenderer);
TRACE("BottomRight:x:%d - y:%d\n", pValueInt[0], pValueInt[1]);
pCoordinate->Delete();

我想知道是否有正确的方法来获得图像角落......