Java结合Swing处理Dicom图像集,实现翻页、左侧缩略图、窗宽位调整
一、代码部分
/**
* @program: yan-api
* @description:
* @author: yc
* @create: 2025-03-17 10:42
**/
public class DicomViewer3 extends JFrame {
// 图像:显示区域
private JLabel imageLabel;
// 状态栏:记录当前索引
private JLabel statusLabel;
// 上一页、下一页按钮
private JButton prevButton;
private JButton nextButton;
private JSlider windowWidthSlider;
private JSlider windowCenterSlider;
private JLabel wwValueLabel;
private JLabel wlValueLabel;
// DICOM文件集合
private List<File> dicomFileList = new ArrayList<>();
// 当前DICOM文件索引
private int currentSliceIndex = -1;
private double[] huPixelData;
private int width, height;
private double rescaleSlope = 1.0;
private double rescaleIntercept = 0.0;
// 缩略图相关变量
private static final int THUMBNAIL_WIDTH = 120;
private static final int PREVIEW_COUNT = 3;
// 创建缩略图面板
private JPanel thumbnailPanel;
private final Map<File, BufferedImage> thumbnailCache = new HashMap<>();
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
DicomViewer3 viewer = new DicomViewer3();
viewer.setVisible(true);
});
}
//............
}
完整代码联系 1393579546@qq.com
二、maven配置
<!--医学图像处理--> <dependency> <groupId>org.dcm4che</groupId> <artifactId>dcm4che-core</artifactId> <version>5.27.0</version> </dependency> <dependency> <groupId>org.dcm4che</groupId> <artifactId>dcm4che-imageio</artifactId> <version>5.27.0</version> </dependency> <dependency> <groupId>org.dcm4che</groupId> <artifactId>dcm4che-imageio-opencv</artifactId> <version>5.27.0</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.dcm4che</groupId> <artifactId>dcm4che-image</artifactId> <version>5.27.0</version> </dependency>