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

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.xdnf.cn/news/3171.html

相关文章:

  • 国内免费连接claude-3-7大模型操作教程
  • 数据库系统综合应用与深度实践指南
  • VINS-FUSION:配置参数说明与配置自己的参数
  • 【XR】MR芯片 和 VR芯片之争
  • Linux:文件操作
  • FEKO许可配置
  • C++负载均衡远程调用学习之Reactor事件触发机制
  • Python3(19)数据结构
  • 第 11 届蓝桥杯 C++ 青少组中 / 高级组省赛 2020 年真题
  • 涨薪技术|0到1学会性能测试第43课-apache status模块监控
  • halcon关闭图形窗口
  • 论文阅读:2024 ICML In-Context Unlearning: Language Models as Few-Shot Unlearners
  • Flink之DataStream
  • URP - 公告牌的效果实现
  • Keysight万用表使用指南及基于Python采集数据生成Excel文件
  • Solon Cloud Gateway 补充
  • 配置 Odoo 的 PostgreSQL 数据库以允许远程访问的步骤
  • 远程深度学习新环境配置流程
  • 力扣-数组-41缺失的第一个正数
  • PDM协议---音频数据接收
  • 「动态规划」线性DP:最长上升子序列(LIS)|编辑距离 / LeetCode 300|72(C++)
  • 浅谈C# record关键字
  • CSS:选择器-基本选择器
  • linux联接服务器SSH-局域网内网穿透分享
  • VR 汽车线束培训:探索高效学习新路径​
  • 线性微分方程与非线性微分方程
  • 工业控制「混合架构」PK大战 —— 神经网络 + MPC vs 模糊 PID+MPC 的场景选型与实战指南
  • 数据转储(go)
  • 网络原理 - 12(HTTP/HTTPS - 3 - 响应)
  • 人工智能数学基础(六):数理统计