我使用 Imerba 库读取 DICOM 文件。 我需要访问像素,以便我可以在低级别修改它们。 文档说:“为了访问图像的像素,您必须检索数据处理程序” 还有一个例子:
imbxUint32 rowSize, channelPixelSize, channelsNumber;
ptr<imebra::handlers::dataHandlerNumericBase> myHandler = presentationImage->getDataHandler(true, &rowSize, &channelPixelSize, &channelsNumber);
// Retrieve the image's size in pixels
imbxUint32 sizeX, sizeY;
presentationImage->getSize(&sizeX, &sizeY);
// Scan all the rows
imbxUint32 index(0);
for(imbxUint32 scanY = 0; scanY < sizeY; ++scanY)
{
// Scan all the columns
for(imbxUint32 scanX = 0; scanX < sizeX; ++scanX)
{
// Scan all the channels
for(imbxUint32 scanChannel = 0; scanChannel < channelsNumber; ++scanChannel)
{
imbxInt32 channelValue = myHandler->getSignedLong(index++);
// Do something with the channel's value
//--------------------------------------
}
}
} 我需要更改 presentationImage 对象像素。我试过像这样改变它:
myHandler->setSignedLong(index,255);
但它不会更改 presentationImage 对象,我现在确定了。 Imebra 文档只有三个示例,并且类和方法描述有点原始。谷歌也一无所知。 如何更改此对象中的像素值?
最佳答案
当您修改缓冲区时,您正在修改未压缩的图像:原始 dicom 结构仍然包含压缩图像。
为了替换 Dicom 文件中的图像,您必须在 dataHandler
超出范围后使用 dataset::setImage
将图像放回数据集中(只有当 dataHandler
被销毁时,数据才会写入图像)
关于c++ - 如何使用 Imebra 库修改 DICOM 文件中的图像像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26919161/