基于cornerstone3D的dicom影像浏览器 第二十四章 显示方位、坐标系、vr轮廓线

系列文章目录


文章目录

  • 系列文章目录
  • 前言
  • 一、工具栏修改
  • 二、切片窗口显示方位文字
    • 1. 修改mprvr.js,添加函数getOrientationMarkers
    • 2. 修改DisplayerArea3D.vue
  • 三、vr窗口显示坐标系
    • 1. 修改mprvr.js 添加OrientationMarkerTool
    • 2. view3d.vue中响应工具栏事件
    • 3. 修改DisplayerArea3D.vue
  • 四、vr窗口显示轮廓线
    • 1. 修改mprvr.js 添加addOutline,showOutline函数
    • 2. view3d.vue中响应工具栏操作
    • 3. 修改DisplayerArea3D.vue
  • 总结


前言

vr = volume rendering 体绘制,体渲染
本章实现三个功能:

  1. mpr窗口中显示方位文字
  2. vr窗口右下角显示坐标系
  3. vr窗口显示轮廓线
    效果如下:
    在这里插入图片描述

一、工具栏修改

  • 在工具栏上添加“VR坐标系”、“VR轮廓”、“方位文字” 三个checkbox,用来控制各自的显示与隐藏。添加select选择器用来切换VR坐标系的显示外观(CUBE, AXES, CUSTOM)。 其中CUSTOM的vtp文件点此处下载
<template><div class="toolbar">...<div class="toolbar-row"><el-checkbox v-model="showAxes" label="VR坐标系" size="large" style="margin: 0 10px" /><el-select v-model="currentAxes" placeholder="Select Axes Type" style="width: 200px"><el-option v-for="item in axes" :key="item.name" :label="item.name" :value="item.value" /></el-select></div><div class="toolbar-row"><el-checkbox v-model="showOutline" label="VR轮廓" size="large" style="margin-left: 10px" /><el-checkbox v-model="showOrientText" label="方位文字" size="large" style="margin-left: 10px" /></div></div>
</template>
  • 监听以上各元素绑定的变量,发送事件到view3d
const currentAxes = ref(1);
const showOutline = ref(true);
const showAxes = ref(true);
const showOrientText = ref(true);watch(showAxes, (newValue) => {emit("action", { name: "showAxes", value: newValue });
});watch(showOutline, (newValue) => {emit("action", { name: "showOutline", value: newValue });
});watch(showOrientText, (newValue) => {emit("action", { name: "toggleOrientText" });
});watch(currentAxes, (newValue) => {emit("action", { name: "changeAxesType", value: newValue });
});

二、切片窗口显示方位文字

计算切片方位文字的算法参考第八章 在Displayer中显示图像方位

1. 修改mprvr.js,添加函数getOrientationMarkers

export default class MPR {constructor(params) {this.toolGroup = null;this.vrToolGroup = null;this.renderingEngine = null;this.registered = false;...this.init(params);}init(config = {}) {...}...getOrientationMarkers({ camera, rotation }) {let flipVertical = camera.flipVertical || false;let flipHorizontal = camera.flipHorizontal || false;let newRotation = rotation || 0;let rowCosines, columnCosines;const { viewUp, viewPlaneNormal } = camera;const viewRight = vec3.create();vec3.cross(viewRight, viewUp, viewPlaneNormal);columnCosines = [-viewUp[0], -viewUp[1], -viewUp[2]];rowCosines = viewRight;const rowString = getOrientationStringLPS(rowCosines);const columnString = getOrientationStringLPS(columnCosines);const oppositeRowString = invertOrientationStringLPS(rowString);const oppositeColumnString = invertOrientationStringLPS(columnString);const markers = {top: oppositeColumnString,left: oppositeRowString,right: rowString,bottom: columnString};// If any vertical or horizontal flips are applied, change the orientation strings ahead of// the rotation applicationsif (flipVertical) {markers.top = invertOrientationStringLPS(markers.top);markers.bottom = invertOrientationStringLPS(markers.bottom);}if (flipHorizontal) {markers.left = invertOrientationStringLPS(markers.left);markers.right = invertOrientationStringLPS(markers.right);}// Swap the labels accordingly if the viewport has been rotated// This could be done in a more complex way for intermediate rotation values (e.g. 45 degrees)if (newRotation === 90 || newRotation === -270) {return {top: markers.left,left: invertOrientationStringLPS(markers.top),right: invertOrientationStringLPS(markers.bottom),bottom: markers.right // left};} else if (newRotation === -90 || newRotation === 270) {return {top: invertOrientationStringLPS(markers.left),left: markers.top,bottom: markers.left,right: markers.bottom};} else if (newRotation === 180 || newRotation === -180) {return {top: invertOrientationStringLPS(markers.top),left: invertOrientationStringLPS(markers.left),bottom: invertOrientationStringLPS(markers.bottom),right: invertOrientationStringLPS(markers.right)};}return markers;}
}

2. 修改DisplayerArea3D.vue

  • 在mpr 三个div上中、下中、左中、右中添加用于显示方位文字的元素。都与变量showOrientText绑定,用来控制显示/隐藏
<template><divclass="container3d"ref="elContainer"v-loading="loading"element-loading-text="正在处理..."element-loading-background="rgba(0, 0, 0, 0.8)"@mousedown.prevent="OnSelectView"><div class="axialparent" :style="axialStyle" v-show="showAxial" @dblclick="OnDbClick"><div ref="elAxial" class="sliceview" @contextmenu.prevent>...<!--显示方位文字--><span class="orient_top" v-show="showOrientText">{{ axialText.orient.top }}</span><span class="orient_bottom" v-show="showOrientText">{{ axialText.orient.bottom }}</span><span class="orient_left" v-show="showOrientText">{{ axialText.orient.left }}</span><span class="orient_right" v-show="showOrientText">{{ axialText.orient.right }}</span></div></div><div class="vrcprparent" v-show="showVR" @dblclick="OnDbClick">...</div><div class="sagittalparent" v-show="showSagittal" @dblclick="OnDbClick"><div ref="elSagittal" class="sliceview" @contextmenu.prevent>...<!--显示方位文字--><span class="orient_top" v-show="showOrientText">{{ sagittalText.orient.top }}</span><span class="orient_bottom" v-show="showOrientText">{{ sagittalText.orient.bottom }}</span><span class="orient_left" v-show="showOrientText">{{ sagittalText.orient.left }}</span><span class="orient_right" v-show="showOrientText">{{ sagittalText.orient.right }}</span></div></div><div class="coronalparent" v-show="showCoronal" @dblclick="OnDbClick"><div ref="elCoronal" class="sliceview" @contextmenu.prevent>...<!--显示方位文字--><span class="orient_top" v-show="showOrientText">{{ coronalText.orient.top }}</span><span class="orient_bottom" v-show="showOrientText">{{ coronalText.orient.bottom }}</span><span class="orient_left" v-show="showOrientText">{{ coronalText.orient.left }}</span><span class="orient_right" v-show="showOrientText">{{ coronalText.orient.right }}</span></div></div></div>
</template>
  • 定义三个切片方位文字的保存变量axialText,sagittalText, coronalText
  • 在onMounted中调用MPR bindCameraEvent绑定CAMERA_MODIFIED事件,调用UdpateOrientation函数
  • 添加cameraHandler,UdpateOrientation函数更新方位文字
import { ViewportId, getDicomInfo } from "../cornerstone3D/mprvr.js";const cornerText = reactive({[ViewportId.AXIAL]: {wwwc: "",slice: "",orient: {top: "",bottom: "",left: "",right: ""}},[ViewportId.SAGITTAL]: {wwwc: "",slice: "",orient: {top: "",bottom: "",left: "",right: ""}},[ViewportId.CORONAL]: {wwwc: "",slice: "",orient: {top: "",bottom: "",left: "",right: ""}}
});const cameraHandler = e => {UdpateOrientation(e);
};const UdpateOrientation = e => {const { viewportId, camera, rotation} = e.detail;const markers = theMPR.getOrientationMarkers({ camera, rotation });if (markers && showOrientText.value) {cornerText[viewportId].orient = markers;}
};onMounted(() => {theMPR = new MPR({elAxial: elAxial.value,elSagittal: elSagittal.value,elCoronal: elCoronal.value,elVR: elVR.value});load();theMPR.bindRenderEvent(renderHandler);theMPR.bindCameraEvent(cameraHandler);});

三、vr窗口显示坐标系

1. 修改mprvr.js 添加OrientationMarkerTool

  • 添加axesConfig 为OrientationMarkerTool定义三种类型外观配置项
  • 添加工具 this.vrToolGroup.addTool(OrientationMarkerTool.toolName, axesConfig)
  • 添加showAxes函数,显示/隐藏坐标系
  • 添加setAxesType函数,切换坐标系外观
  • loadImages中调用this.showAxes(true),显示默认坐标系-CUBE
const {ToolGroupManager,Enums: csToolsEnums,...OrientationMarkerTool
} = cornerstoneTools;const axesConfig = {orientationWidget: {viewportSize: 0.08,minPixelSize: 70,maxPixelSize: 200},overlayMarkerType: OrientationMarkerTool.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE,overlayConfiguration: {[OrientationMarkerTool.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE]: {faceProperties: {xPlus: {text: "L",faceColor: viewportColors[idSagittal], //"#ffff00",faceRotation: 90},xMinus: {text: "R",faceColor: viewportColors[idSagittal], //"#ffff00",faceRotation: 270},yPlus: {text: "P",faceColor: viewportColors[idCoronal], //"#00ffff",fontColor: "black",faceRotation: 180},yMinus: {text: "A",faceColor: viewportColors[idCoronal], //"#00ffff",fontColor: "black"},zPlus: {text: "S",faceColor: viewportColors[idAxial] //"#00ffff",// fontColor: "white",},zMinus: {text: "I",faceColor: viewportColors[idAxial] //"#00ffff",// fontColor: "white",}},defaultStyle: {fontStyle: "bold",fontFamily: "Arial",fontColor: "black",fontSizeScale: res => res / 2,faceColor: "#0000ff",edgeThickness: 0.05,edgeColor: "black",resolution: 400}},[OrientationMarkerTool.OVERLAY_MARKER_TYPES.AXES]: {},[OrientationMarkerTool.OVERLAY_MARKER_TYPES.CUSTOM]: {polyDataURL: "/src/assets/Human.vtp"}}
};export default class MPR {constructor(params) {this.toolGroup = null;this.vrToolGroup = null;this.renderingEngine = null;this.registered = false;this.viewportInputArray = null;this.crosshairsToolActive = true;this.loaded = false;this.selecteToolName = "";this.params = params;this.volume = null;this.init(params);}init(config = {}) {const { elAxial, elSagittal, elCoronal, elVR } = config;cornerstoneTools.addTool(CrosshairsTool);...cornerstoneTools.addTool(OrientationMarkerTool);this.vrToolGroup = ToolGroupManager.getToolGroup(vrToolGroupId);if (!this.vrToolGroup) {this.vrToolGroup = ToolGroupManager.createToolGroup(vrToolGroupId);this.vrToolGroup.addTool(TrackballRotateTool.toolName);this.vrToolGroup.addTool(ZoomTool.toolName, {zoomToCenter: true,invert: true,minZoomScale: 0.15,maxZoomScale: 20});...// 添加坐标系工具this.vrToolGroup.addTool(OrientationMarkerTool.toolName, axesConfig);}}async loadImages(imageIds) {let newImageIds = [...new Set(imageIds)];for (let i = 0; i < newImageIds.length; i++) {await cornerstoneDICOMImageLoader.wadouri.loadImage(newImageIds[i]).promise;}// Define a volume in memorythis.volume = await volumeLoader.createAndCacheVolume(volumeId, {imageIds: newImageIds});...// 显示坐标系this.showAxes(true);this.loaded = true;}...setAxesType(type) {  // 坐标系外观axesConfig.overlayMarkerType = type;const options = this.vrToolGroup.getToolOptions(OrientationMarkerTool.toolName);if (options.mode === "Enabled") {this.vrToolGroup.setToolDisabled(OrientationMarkerTool.toolName);this.vrToolGroup.setToolConfiguration(OrientationMarkerTool.toolName, {overlayMarkerType: type});this.vrToolGroup.setToolEnabled(OrientationMarkerTool.toolName);}}showAxes(show) {  // 显示/隐藏坐标系if (show) {this.vrToolGroup.setToolConfiguration(OrientationMarkerTool.toolName, {overlayMarkerType: axesConfig.overlayMarkerType});this.vrToolGroup.setToolEnabled(OrientationMarkerTool.toolName);} else {this.vrToolGroup.setToolDisabled(OrientationMarkerTool.toolName);}}
}

2. view3d.vue中响应工具栏事件

async function OnToolbarAction(action) {switch (action.name) {...case "showOutline":  // 显示/隐藏 轮廓线displayArea.value.showOutline(action.value);break;case "showAxes":  // 显示/隐藏 坐标系displayArea.value.showAxes(action.value);break;case "toggleOrientText":  // 显示/隐藏 切片窗口方位文字displayArea.value.toggleOrientText();break;case "changeAxesType":  // 切换坐标系外观displayArea.value.changeAxesType(action.value);break;default:break;}
}

3. 修改DisplayerArea3D.vue

添加并导出工具栏操作响应函数:showAxes,changeAxesType

const showAxes = show => {theMPR.showAxes(show);
};const changeAxesType = type => {theMPR.setAxesType(type);
};defineExpose({...showAxes,changeAxesType,
});

四、vr窗口显示轮廓线

1. 修改mprvr.js 添加addOutline,showOutline函数

  • 导入vtk.js中的vtkOutlineFilter,vtkMapper,vtkActor
  • 添加addOutline函数,vtkOutlineFilter输入连接this.volume.imageData
  • 添加showOutline函数,显示/隐藏轮廓线
  • loadImages中调用this.showOutline(true),默认显示轮廓线
import vtkOutlineFilter from "@kitware/vtk.js/Filters/General/OutlineFilter";
import vtkMapper from "@kitware/vtk.js/Rendering/Core/Mapper";
import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";let outlineActor = null;export default class MPR {constructor(params) {this.toolGroup = null;this.vrToolGroup = null;...this.init(params);}init(config = {}) {...}...addOutline() {// Create image outline in 3D viewconst outline = vtkOutlineFilter.newInstance();const mapper = vtkMapper.newInstance();outlineActor = vtkActor.newInstance();outlineActor.setMapper(mapper);outline.setInputData(this.volume.imageData);mapper.setInputData(outline.getOutputData());const viewport = this.renderingEngine.getViewport(idVolume);viewport.addActor({ uid: "VOLUME_OUTLINE", actor: outlineActor });outlineActor.setVisibility(true);viewport.render();}showOutline(show) {if (!outlineActor) return;outlineActor.setVisibility(show);const viewport = this.renderingEngine.getViewport(idVolume);viewport.render();}
}

2. view3d.vue中响应工具栏操作

参考第三节

3. 修改DisplayerArea3D.vue

添加并导出工具栏操作响应函数:showOutline

const showOutline = show => {theMPR.showOutline(show);
};defineExpose({...showOutline
});

总结

mpr切片窗口显示/隐藏 方位文字。
vr窗口显示/隐藏坐标系,切换坐标系外观
vr窗口显示/隐藏轮廓线。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/pingmian/82518.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【C/C++】线程局部存储:原理与应用详解

文章目录 1 基础概念1.1 定义1.2 初始化规则1.3 全局TLS vs 局部静态TLS 2 内存布局2.1 实现机制2.2 典型内存结构2.3 性能特点 3 使用场景/用途3.1 场景3.2 用途 4 注意事项5 对比其他技术6 示例代码7 建议7.1 调试7.2 优化 8 学习资料9 总结 在 C 多线程编程中&#xff0c;线…

【图像大模型】IP-Adapter:图像提示适配器的技术解析与实践指南

IP-Adapter&#xff1a;图像提示适配器的技术解析与实践指南 一、项目背景与技术价值1.1 图像生成中的个性化控制需求1.2 IP-Adapter的核心贡献 二、技术原理深度解析2.1 整体架构设计2.2 图像特征编码器2.3 训练策略 三、项目部署与实战指南3.1 环境配置3.2 模型下载3.3 基础生…

MySQL-5.7 修改密码和连接访问权限

一、MySQL-5.7 修改密码和连接权限设置 修改密码语法 注意&#xff1a;rootlocalhost 和 root192.168.56.% 是两个不同的用户。在修改密码时&#xff0c;两个用户的密码是各自分别保存&#xff0c;如果两个用户密码设置不一样则登陆时注意登陆密码 GRANT ALL PRIVILEGES ON …

Linux基本指令篇 —— touch指令

touch是Linux和Unix系统中一个非常基础但实用的命令&#xff0c;主要用于操作文件的时间戳和创建空文件。下面我将详细介绍这个命令的用法和功能。 目录 一、基本功能 1. 创建空文件 2. 同时创建多个文件 3. 创建带有空格的文件名&#xff08;需要使用引号&#xff09; 二、…

mysql explain使用

文章目录 type 访问类型性能高到低多注意type: index 出现的场景 key 实际使用的索引Extra 额外信息其他字段 通过 EXPLAIN 你可以知道&#xff1a;如是否使用索引、扫描多少行、是否需要排序或临时表 EXPLAIN 三板斧&#xff08;type、key、Extra&#xff09; 例子&#xff1…

JMeter-SSE响应数据自动化

结构图 背景&#xff1a; 需要写一个JMeter脚本来进行自动化测试&#xff0c;主要是通过接口调用一些东西&#xff0c;同时要对响应的数据进行处理&#xff0c;包括不限于错误信息的输出。 1.SSE(摘录) SSE&#xff08;Server-Sent Events&#xff09;是一种基于HTTP协议、允许…

<<运算符重载 和 c_str() 的区别和联系

例题 文章开始之前我们看下以下代码&#xff0c;你能精准的说出正确的输出结果并知道其原理吗&#xff1f; void test() {string s1("hello world");cout << s1 << endl;//cout << s1.c_str() << endl;//const char* p1 "xxxx"…

python web flask专题-Flask入门指南:从安装到核心功能详解

Flask入门指南&#xff1a;从安装到核心功能详解 Flask作为Python最流行的轻量级Web框架之一&#xff0c;以其简洁灵活的特性广受开发者喜爱。本文将带你从零开始学习Flask&#xff0c;涵盖安装配置、项目结构、应用实例、路由系统以及请求响应处理等核心知识点。 1. Flask安…

一种C# 的SM4 的 加解密的实现,一般用于医疗或者支付

一种C# 的SM4 的 加解密的实现 一般用于医疗或者支付 加密 string cipherText SM4Helper.Encrypt_test(data, key); public static string Encrypt_test(string plainText, string key) { byte[] keyBytes Encoding.ASCII.GetBytes(key); byte[] input…

“轩辕杯“云盾砺剑CTF挑战赛 Web wp

文章目录 ezflaskezjsezrceezssrf1.0签到ezsql1.0ez_web1非预期预期解 ezflask ssti, 过滤了一些关键词, 绕一下就行 name{{url_for["__globals__"]["__builtins__"]["eval"]("__tropmi__"[::-1])(os)["po""pen"…

Matlab快速上手五十六:详解符号运算里假设的用法,通过假设可以设置符号变量的取值范围,也可以通过假设设置变量属于集合:整数、正数和实数等

1.符号变量中假设的概念 在符号数学工具箱中&#xff0c;符号变量默认范围是全体复数&#xff0c;也就是说&#xff0c;符号运算是在全体复数域进行的&#xff0c;若需要运算中&#xff0c;不使用全体复数域&#xff0c;可以为变量设定取值范围&#xff0c;这就用到了假设&…

【python实用小脚本-79】[HR转型]Excel难民到数据工程师|用Python实现CSV秒转JSON(附HRIS系统对接方案)

场景故事&#xff1a;从手动复制粘贴到自动化数据流转 "Kelly&#xff0c;我们需要把3000名员工的考勤数据导入新HR系统&#xff0c;今天能完成吗&#xff1f;"去年这个时候&#xff0c;作为HRIS项目负责人的我&#xff0c;面对这个需求时第一反应是打开Excel开始手…

数据透视:水安 B 证如何影响水利企业的生存指数?

某大数据公司提取了 3000 家水利企业的经营数据&#xff0c;一组关联分析令人震惊&#xff1a;B 证配备率与企业利润率的相关系数达 0.67—— 这意味着持证率每提升 10%&#xff0c;企业利润率平均提高 4.2 个百分点。当我们用数据解剖这本红本本&#xff0c;会发现它像一根无形…

从零搭建上门做饭平台:高并发订单系统设计

你知道为什么聪明人都在抢着做上门做饭平台吗&#xff1f;因为这可能是餐饮行业最后一片蓝海&#xff01;传统餐饮还在为房租人工发愁时&#xff0c;上门私厨已经轻装上阵杀出重围。不需要门店租金&#xff0c;不用养服务员&#xff0c;厨师直接上门服务&#xff0c;成本直降60…

openpi π₀ 项目部署运行逻辑(四)——机器人主控程序 main.py — aloha_real

π₀ 机器人主控脚本都在 examples 中&#xff1a; 可以看到包含了多种类机器人适配 此笔记首先记录了 aloha_real 部分 aloha_real 中&#xff0c;main.py 是 openpi ALOHA 平台上“主控执行入口”&#xff0c;负责&#xff1a; 建立与推理服务器&#xff08;serve_policy.…

利用 Python 爬虫获取唯品会 VIP 商品详情:实战指南

在当今电商竞争激烈的环境中&#xff0c;VIP 商品往往是商家的核心竞争力所在。这些商品不仅代表着品牌的高端形象&#xff0c;更是吸引高价值客户的关键。因此&#xff0c;获取 VIP 商品的详细信息对于市场分析、竞品研究以及优化自身产品策略至关重要。Python 作为一种强大的…

鸿蒙桌面快捷方式开发

桌面快捷方式开发实战 [参考文档] (https://developer.huawei.com/consumer/cn/doc/best-practices/bpta-desktop-shortcuts) 在module.json5配置文件中的abilities标签下的metadata中设置resource属性值为$profile:shortcuts_config&#xff0c;指定应用的快捷方式配置文件&…

3分钟学会跨浏览器富文本编辑器开发:精准光标定位+内容插入(附完整代码)

一、痛点直击&#xff1a;传统编辑器的三大坑 作为前端开发&#xff0c;你是否遇到过以下灵魂拷问&#xff1f; ✅ 为什么Firefox光标能精准定位&#xff0c;IE却永远跳转到开头&#xff1f;✅ 图片上传后如何保证插入位置不偏移&#xff1f;✅ 跨浏览器兼容测试时&#xff0…

RK3562 Linux-5.10 内核HUSB311 Type-C 控制器芯片调试记录

硬件原理&#xff1a; 1. type C 接口&#xff1a; 1.1 HUSB311芯片&#xff0c; CC1和CC2 逻辑接到HUSB311 上面&#xff0c; 接I2C0组和USBCC_INT_L USBCC_INT_L 接到GPIO0_A6 做为CC的逻辑中断 1.2 TYPEC_DP/TYPEC_DM 接到ARM 端的USB3.0 OTG上面 1.2 TYPEC_RX1P/TYPEC…

深入理解Java中的BigDecimal:高精度计算的核心工具

精心整理了最新的面试资料和简历模板&#xff0c;有需要的可以自行获取 点击前往百度网盘获取 点击前往夸克网盘获取 引言 在Java编程中&#xff0c;处理浮点数运算时可能会遇到精度丢失的问题。例如&#xff1a; System.out.println(0.1 0.2); // 输出&#xff1a;0.30000…