调整Dicomimage的窗口

时间:2018-10-18 12:47:41

标签: java dicom dcm4che

我正在编写一个简单的dicom查看器。我想在范围滑块的帮助下对Dicom图像进行窗口处理。但是当我移动该区域时,图像不会改变。

Rangeslider的初始化:

DICOM temp = listImages.getSelectionModel().getSelectedItem();
double minValue = temp.getWindowCenter() - (temp.getWindowWidth() / 2);
double maxValue = temp.getWindowCenter() + (temp.getWindowWidth() / 2);
windowing.setMin(temp.getMinHU());
windowing.setMax(temp.getMaxHU());
windowing.setLowValue(minValue);
windowing.setHighValue(maxValue);

更改值事件:

windowing.lowValueProperty().addListener((Observable o) -> {
        try {

            if (displayImage) {
                double windowWidth = windowing.getLowValue() - windowing.getHighValue();
                double windowCenter = windowWidth / 2;
                DICOM temp = listImages.getSelectionModel().getSelectedItem();
                temp.setWindowWidth(windowWidth);
                temp.setWindowCenter(windowCenter);
                viewImage.setImage(SwingFXUtils.toFXImage(temp.getBufferedImage(), null));
            }
        } catch (IOException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    windowing.highValueProperty().addListener(o -> {
        try {
            if (displayImage) {
                double windowWidth = windowing.getLowValue() - windowing.getHighValue();
                double windowCenter = windowWidth / 2;
                DICOM temp = listImages.getSelectionModel().getSelectedItem();
                temp.setWindowWidth(windowWidth);
                temp.setWindowCenter(windowCenter);
                viewImage.setImage(SwingFXUtils.toFXImage(temp.getBufferedImage(), null));
            }
        } catch (IOException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

我希望任何人都能帮忙。

0 个答案:

没有答案