当前位置: 首页 > news >正文

Learning vtkjs之ImageMarchingSquares

体积 等值线处理

介绍

vtkImageMarchingSquares - 对图像(或来自体积的切片)进行等值线处理

给定一个指定的等值,使用Marching Squares算法(3D Marching Cubes算法的2D版本)生成等值线。

效果

在这里插入图片描述
自己增加了两个小球,主要是对比一下ISO前后的效果

核心代码

参数更新

const updateParam = (value) => {const { mSquares, renderWindow } = context.current;mSquares.setSlicingMode(value);setState({...state,slicingMode: value,});renderWindow.render();};

主要流程

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({background: [0, 0, 0],rootContainer: vtkContainerRef.current,});const renderer = fullScreenRenderer.getRenderer();const renderWindow = fullScreenRenderer.getRenderWindow();const { Operation } = vtkImplicitBoolean;const actor = vtkActor.newInstance();renderer.addActor(actor);const mapper = vtkMapper.newInstance();actor.setMapper(mapper);// Build pipelineconst sphere = vtkSphere.newInstance({center: [-2.5, 0.0, 0.0],radius: 3.0,});const sphere2 = vtkSphere.newInstance({center: [2.5, 0.0, 0.0],radius: 0.5,});// const plane = vtkPlane.newInstance({ origin: [0, 0, 0], normal: [0, 1, 0] });const impBool = vtkImplicitBoolean.newInstance({operation: Operation.UNION,functions: [sphere, sphere2],});const sample = vtkSampleFunction.newInstance({implicitFunction: impBool,sampleDimensions: [50, 50, 50],modelBounds: [-5.0, 5.0, -2.0, 2.0, -1.0, 1.0],});// Isocontourconst mSquares = vtkImageMarchingSquares.newInstance({ slice: 1 });mSquares.setSlicingMode(2);// Connect the pipeline propermSquares.setInputConnection(sample.getOutputPort());mapper.setInputConnection(mSquares.getOutputPort());// Update the pipeline to obtain metadata (range) about scalarssample.update();const cValues = [];const [min, max] = sample.getOutputData().getPointData().getScalars().getRange();const step = 20;for (let i = 0; i < step; ++i) {cValues[i] = min + (i / (step - 1)) * (max - min);}mSquares.setContourValues(cValues);mSquares.setSlice(25);// Create an outline// Bounding boxconst outline = vtkOutlineFilter.newInstance();outline.setInputConnection(sample.getOutputPort());const outlineMapper = vtkMapper.newInstance();outlineMapper.setInputConnection(outline.getOutputPort());const outlineActor = vtkActor.newInstance();outlineActor.setMapper(outlineMapper);renderer.addActor(outlineActor);context.current = {mSquares,renderer,renderWindow,};// 同步sphereconst sphereReference = createSphere([-2.5, 0.0, 0.0], 3.0);renderer.addActor(sphereReference);const sphereReference2 = createSphere([2.5, 0.0, 0.0], 0.5);renderer.addActor(sphereReference2);renderer.resetCamera();renderWindow.render();

全部代码都放到github上了
新坑_Learning vtkjs_git地址
关注我,我持续更新vtkjs的example学习案例

也欢迎各位给我提意见,技术交流~

大鸿

WeChat : HugeYen
WeChat Public Account : BIM树洞

做一个静谧的树洞君

用建筑的语言描述IT事物;

用IT的思维解决建筑问题;

共建BIM桥梁,聚合团队。

本学习分享资料不得用于商业用途,仅做学习交流!!如有侵权立即删除!!

http://www.dtcms.com/a/166498.html

相关文章:

  • 在Java中使用Files类的copy()方法复制文件的示例
  • Ubuntu20.04安装NVIDIA Warp
  • 【数据结构】——顺序表刷题
  • Linux远程管理
  • WPACS基于HTML5的DICOM影像浏览
  • 92.一个简单的输入与显示示例 Maui例子 C#例子
  • 【计算机视觉】目标检测:深度解析MMDetection:OpenMMLab开源目标检测框架实战指南
  • C++中std::map、std::list和std::deque的底层实现是怎样的?
  • 2025 新生 DL-FWI 培训
  • MT6765 android上层获取VCM lens位置
  • 上海地区IDC机房服务器托管选型报告(2025年4月30日)
  • Power Automate:发送邮件时加入表格
  • pinia实现数据持久化插件pinia-plugin-persist-uni
  • w313安康学院新型冠状病毒肺炎疫情防控专题网站设计与实现
  • MySQL慢查询日志分析工具mysqldumpslow教程
  • Roboflow标注数据集
  • 【MCP Node.js SDK 全栈进阶指南】高级篇(6):MCP服务大规模部署方案
  • 安卓AppWidget桌面小组件在国产移动设备的一些适配问题
  • 驱动车辆诊断测试创新 | 支持诊断测试的模拟器及数据文件转换生成
  • pybind11 使用指南+示例
  • 【AI论文】RepText:通过复制渲染视觉文本
  • java访问修饰符
  • SSM学习
  • LibAI Lab走进西浦:重塑“AI+建筑”教育
  • C语言之操作符
  • 从 PID 到 Agent:工业控制算法的五代进化史与智能协同革命
  • 哪些因素会影响远程视频监控的质量?浅述EasyCVR视频智能诊断技术
  • 手动创建一份konga对应helm的chart项目
  • 【学习笔记】机器学习(Machine Learning) | 第五章(1)| 分类与逻辑回归
  • 浅谈C# record关键字