简体   繁体   English

来自pixelmed的dicom bufferedImage具有低对比度

[英]The dicom bufferedImage from pixelmed is having low contrast

I would like to display a DICOM image in my java program. 我想在我的Java程序中显示DICOM图像。 I am using pixelmed. 我正在使用pixelmed。 However, I found that i cant correctly display the correct contrast. 但是,我发现我无法正确显示正确的对比度。 The contrast is too low. 对比度太低。

Here is my code: 这是我的代码:

(SourceImage is a class provided by PixelMed, chosenImageFile.getPath() is just the path of the DICOM File.) (SourceImage是PixelMed提供的类,selectedImageFile.getPath()只是DICOM文件的路径。)

SourceImage dimg = new SourceImage(chosenImageFile.getPath());
BufferedImage image = dimg.getBufferedImage();

BufferedImage source = new BufferedImage(image.getWidth(), image.getHeight(),    BufferedImage.TYPE_INT_RGB);

Graphics2D g2d = source.createGraphics();
g2d.drawImage(image, 0, 0, null);
dicomImgDisplayer1.setImage(source);

dicomImgDisplayer1 is an class extend JPanel. dicomImgDisplayer1是类扩展JPanel。 setImage() of this JPanel class will call the setImage() of an JFrame class. 此JPanel类的setImage()将调用JFrame类的setImage()。

The JFrame class's setImage() code: JFrame类的setImage()代码:

public void setImage(BufferedImage image) {
   this.image = image;
   setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
   repaint();
   revalidate();
}

public void paint(Graphics graphics) {
   Graphics2D g2d = (Graphics2D) graphics;
   g2d.drawImage(image, null, 0, 0);
}

Is that something wrong with the color model? 颜色模型有问题吗? Please help. 请帮忙。 Thanks. 谢谢。

Does your image have a prescribed window width / window center? 您的图像是否具有规定的窗口宽度/窗口中心? Be sure you set that (or allow the user to adjust it). 确保设置(或允许用户调整)。 See SingleImagePanel - there are some static methods to apply windowing to your buffered image. 请参见SingleImagePanel-有一些静态方法可以将窗口应用于缓冲的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM