Imebra 库显示传输语法 1.2.840.10008.1.2.1 的完全灰色图像
Imebra library shows completely gray image for transfer syntax 1.2.840.10008.1.2.1
我正在尝试使用 Imebra 库在 android 中显示 DICOM 图像。我正在使用该库的 5.0 版。
显示的位图完全是灰色的,图像的传输语法是 1.2.840.10008.1.2。1.For 其他支持的传输语法,即 JPEG,它工作正常。
此外,我无法添加 VOILUT 转换功能,如文档中所述,它给出了错误的 constructor not found for VOILUT。
下面是我正在使用的代码,VOILUT 转换部分给出了未找到的构造函数。如果我删除 VOILUT 变换部分,一切正常,但对于传输语法为 1.2.840.10008.1.2.1 的图像,它显示完全灰色图像
private Bitmap fromDicom(String filePath, int frameNumber){
// have been applied).
Image dicomImage = loadedDataSet.getImageApplyModalityTransform(frameNumber);
// Use a DrawBitmap to build a stream of bytes that can be handled by the
// Android Bitmap class.
com.imebra.TransformsChain chain = new com.imebra.TransformsChain();
if( com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace()))
{
// Retrieve the VOIs (center/width pairs)
com.imebra.VOIs vois = loadedDataSet.getVOIs();
if(!vois.isEmpty())
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.SWIGTYPE_p_imebra__VOIDescription voiDescription = VOILUT.getOptimalVOI(dicomImage, 0, 0, dicomImage.getWidth(), dicomImage.getHeight());
chain.addTransform(new VOILUT(voiDescription));
}
}
DrawBitmap drawBitmap = new DrawBitmap(chain);
Memory memory = drawBitmap.getBitmap(dicomImage, drawBitmapType_t.drawBitmapRGBA, 4);
// Build the Android Bitmap from the raw bytes returned by DrawBitmap.
Bitmap renderBitmap = Bitmap.createBitmap((int)dicomImage.getWidth(), (int)dicomImage.getHeight(), Bitmap.Config.ARGB_8888);
byte[] memoryByte = new byte[(int)memory.size()];
memory.data(memoryByte);
ByteBuffer byteBuffer = ByteBuffer.wrap(memoryByte);
renderBitmap.copyPixelsFromBuffer(byteBuffer);
// Update the image
return renderBitmap;
}
更改您建议的代码后,我找不到 class 提到的内容
VOIDescription 而不是我看到 class SWIGTYPE_p_imebra__VOIDescription 我应该使用那个 class
还有一个错误 vois.get(0).getWidth
没有可用的 getWidth() 方法
最后一个错误我没有看到 class vois_t 相反有一个 class VOI 应该使用 VOI
感谢您的回复
VOILUT 必须使用数据集中的适当对比度设置进行初始化,如下面的代码所示。
但是,数据集包含错误的 VOI 设置(window 宽度为 0),因此只有使用自定义 VOI 才能正确显示此文件设置或仅在宽度为零时使用自动设置(请参阅下面检查宽度 > 0 的替代代码)。
不检查宽度的代码:
if(com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace());
{
// Retrieve the VOIs (center/width pairs)
com.imebra.vois_t vois = loadedDataSet.getVOIs();
if(!vois.isEmpty())
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.VOIDescription voiDescription = VOILUT.getOptimalVOI(dataSetImage, 0, 0, width, height);
chain.addTransform(new VOILUT(voiDescription));
}
}
检查宽度是否为 0 的替代代码:
if(com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace());
{
// Retrieve the VOIs (center/width pairs)
com.imebra.vois_t vois = loadedDataSet.getVOIs();
if(!vois.isEmpty() && vois.get(0).getWidth() > 0.1)
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.VOIDescription voiDescription = VOILUT.getOptimalVOI(dataSetImage, 0, 0, width, height);
chain.addTransform(new VOILUT(voiDescription));
}
}
我正在尝试使用 Imebra 库在 android 中显示 DICOM 图像。我正在使用该库的 5.0 版。 显示的位图完全是灰色的,图像的传输语法是 1.2.840.10008.1.2。1.For 其他支持的传输语法,即 JPEG,它工作正常。
此外,我无法添加 VOILUT 转换功能,如文档中所述,它给出了错误的 constructor not found for VOILUT。
下面是我正在使用的代码,VOILUT 转换部分给出了未找到的构造函数。如果我删除 VOILUT 变换部分,一切正常,但对于传输语法为 1.2.840.10008.1.2.1 的图像,它显示完全灰色图像
private Bitmap fromDicom(String filePath, int frameNumber){
// have been applied).
Image dicomImage = loadedDataSet.getImageApplyModalityTransform(frameNumber);
// Use a DrawBitmap to build a stream of bytes that can be handled by the
// Android Bitmap class.
com.imebra.TransformsChain chain = new com.imebra.TransformsChain();
if( com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace()))
{
// Retrieve the VOIs (center/width pairs)
com.imebra.VOIs vois = loadedDataSet.getVOIs();
if(!vois.isEmpty())
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.SWIGTYPE_p_imebra__VOIDescription voiDescription = VOILUT.getOptimalVOI(dicomImage, 0, 0, dicomImage.getWidth(), dicomImage.getHeight());
chain.addTransform(new VOILUT(voiDescription));
}
}
DrawBitmap drawBitmap = new DrawBitmap(chain);
Memory memory = drawBitmap.getBitmap(dicomImage, drawBitmapType_t.drawBitmapRGBA, 4);
// Build the Android Bitmap from the raw bytes returned by DrawBitmap.
Bitmap renderBitmap = Bitmap.createBitmap((int)dicomImage.getWidth(), (int)dicomImage.getHeight(), Bitmap.Config.ARGB_8888);
byte[] memoryByte = new byte[(int)memory.size()];
memory.data(memoryByte);
ByteBuffer byteBuffer = ByteBuffer.wrap(memoryByte);
renderBitmap.copyPixelsFromBuffer(byteBuffer);
// Update the image
return renderBitmap;
}
更改您建议的代码后,我找不到 class 提到的内容
VOIDescription 而不是我看到 class SWIGTYPE_p_imebra__VOIDescription 我应该使用那个 class
还有一个错误 vois.get(0).getWidth
没有可用的 getWidth() 方法最后一个错误我没有看到 class vois_t 相反有一个 class VOI 应该使用 VOI
感谢您的回复
VOILUT 必须使用数据集中的适当对比度设置进行初始化,如下面的代码所示。
但是,数据集包含错误的 VOI 设置(window 宽度为 0),因此只有使用自定义 VOI 才能正确显示此文件设置或仅在宽度为零时使用自动设置(请参阅下面检查宽度 > 0 的替代代码)。
不检查宽度的代码:
if(com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace());
{
// Retrieve the VOIs (center/width pairs)
com.imebra.vois_t vois = loadedDataSet.getVOIs();
if(!vois.isEmpty())
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.VOIDescription voiDescription = VOILUT.getOptimalVOI(dataSetImage, 0, 0, width, height);
chain.addTransform(new VOILUT(voiDescription));
}
}
检查宽度是否为 0 的替代代码:
if(com.imebra.ColorTransformsFactory.isMonochrome(dicomImage.getColorSpace());
{
// Retrieve the VOIs (center/width pairs)
com.imebra.vois_t vois = loadedDataSet.getVOIs();
if(!vois.isEmpty() && vois.get(0).getWidth() > 0.1)
{
// Get the first VOI setting from the dataset
chain.addTransform(new VOILUT(vois.get(0)));
}
else
{
// The dataset does not have any VOI setting, find the optimal one
com.imebra.VOIDescription voiDescription = VOILUT.getOptimalVOI(dataSetImage, 0, 0, width, height);
chain.addTransform(new VOILUT(voiDescription));
}
}