体绘制管线Imagedata->=VolumeMapper->Volume->Render->RenderWindow->RenderWindowInteractor

SetBlendModeToComposite()

Set/Get the blend mode.

The default mode is Composite where the scalar values are sampled through the volume and composited in a front-to-back scheme through alpha blending. The final color and opacity is determined using the color and opacity transfer functions.

Maximum and minimum intensity blend modes use the maximum and minimum scalar values, respectively, along the sampling ray. The final color and opacity is determined by passing the resultant value through the color and opacity transfer functions.

Additive blend mode accumulates scalar values by passing each value through the opacity transfer function and then adding up the product of the value and its opacity. In other words, the scalar values are scaled using the opacity transfer function and summed to derive the final color. Note that the resulting image is always grayscale i.e. aggregated values are not passed through the color transfer function. This is because the final value is a derived value and not a real data value along the sampling ray.

Average intensity blend mode works similar to the additive blend mode where the scalar values are multiplied by opacity calculated from the opacity transfer function and then added. The additional step here is to divide the sum by the number of samples taken through the volume. One can control the scalar range by setting the AverageIPScalarRange ivar to disregard scalar values, not in the range of interest, from the average computation. As is the case with the additive intensity projection, the final image will always be grayscale i.e. the aggregated values are not passed through the color transfer function. This is because the resultant value is a derived value and not a real data value along the sampling ray.

IsoSurface blend mode uses contour values defined by the user in order to display scalar values only when the ray crosses the contour. It supports opacity the same way composite blend mode does.

代码:

void MainWindow::ImageSliceTo3D(){//生成图像序列的文件名数组
vtkSmartPointer <vtkStringArray> fileArray = vtkSmartPointer <vtkStringArray>::New();
char fileName[128];
for(int i = 1; i < 100; i++)
{sprintf(fileName, "VTK_test/Head/head%03d.jpg", i);std::string fileStr(fileName);fileArray->InsertNextValue(fileStr);
}
//读取JPG序列图像
vtkSmartPointer <vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();reader->SetFileNames(fileArray);reader->Update();vtkSmartPointer <vtkSmartVolumeMapper> volumeMapper=vtkSmartPointer <vtkSmartVolumeMapper>::New();volumeMapper->SetBlendModeToComposite();volumeMapper->SetInputData(reader->GetOutput());vtkSmartPointer <vtkVolumeProperty> volumeProperty=vtkSmartPointer <vtkVolumeProperty>::New();volumeProperty->ShadeOff();//关闭阴影volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);vtkSmartPointer <vtkPiecewiseFunction> compositeOpacity=vtkSmartPointer <vtkPiecewiseFunction>::New();compositeOpacity->AddPoint(0.0, 0);//设置像素值小于0的明度为0compositeOpacity->AddPoint(255.0, 1.0);//设置像素值大于255的明度为1volumeProperty->SetScalarOpacity(compositeOpacity);vtkSmartPointer <vtkVolume> volume=vtkSmartPointer <vtkVolume>::New();volume->SetMapper(volumeMapper);volume->SetProperty(volumeProperty);vtkSmartPointer <vtkRenderer> render=vtkSmartPointer <vtkRenderer>::New();render->SetBackground(0.1, 0.4, 0.2);render->AddVolume(volume);vtkSmartPointer <vtkRenderWindow> rw=vtkSmartPointer <vtkRenderWindow>::New();rw->SetSize(512,512);rw->AddRenderer(render);vtkSmartPointer <vtkRenderWindowInteractor> rwi=vtkSmartPointer                 <vtkRenderWindowInteractor>::New();rwi->SetRenderWindow(rw);rw->Render();rwi->Initialize();rwi->Start();}

效果:

​​​​​​​

参考链接:

https://kitware.github.io/vtk-examples/site/Cxx/VolumeRendering/SmartVolumeMapper/https://kitware.github.io/vtk-examples/site/Cxx/VolumeRendering/SmartVolumeMapper/

VTK: vtkVolumeMapper Class Referencehttps://vtk.org/doc/nightly/html/classvtkVolumeMapper.html#ac17e07d033289f756622d1e7b2a6a0ea

VTK 体绘制讨论_不透明度传输函数 - 一杯清酒邀明月 - 博客园 (cnblogs.com)https://www.cnblogs.com/ybqjymy/p/14239936.html

VTK学习笔记(二)-----读入序列图像进行三维体渲染相关推荐

  1. 基于序列图像的三维体绘的视线投射算法

    基于序列图像的三维体绘的视线投射算法(Ray Casting) 一.体绘算法步骤   1.体数据的生成: 将序列图像的象素数据部分剥离出来(如果是JPG等压缩类型的数据,还需要先解压缩),按照相对的上 ...

  2. OpenCv学习笔记(二)--Mat矩阵(图像容器)的创建及CV_8UC1,CV_8UC2等参数详解

    (一)Mat矩阵(图像容器)创建时CV_8UC1,CV_8UC2等参数详解 1--Mat不但是一个非常有用的图像容器类,同时也是一个通用的矩阵类 2--创建一个Mat对象的方法很多,我们现在先看一下M ...

  3. VTK学习笔记(三十六)VTK图像填充

    VTK学习笔记(三十六)VTK图像填充 1.官方示例 2.其他例子 总结 1.官方示例 来自官方示例代码,自己只是添加了理解. 代码: #include <vtkCamera.h> #in ...

  4. VTK学习笔记(二十一)vtk裁剪求截面面积

    VTK学习笔记(二十一)vtk裁剪求界面面积 1.代码 2.CMakeLists.txt 3.运行输出 4.面积正确性验证 4.1.代码 4.2.执行结果 1.代码 #pragma once#incl ...

  5. VTK学习笔记3:IO操作读取写入xml文件和vtk文件

    1.vtu文件 vtk实战(二十四)--读入vtu数据 vtk实战(三十)--写入vtu数据 2.vtp文件 2.1读入vtp文件 2.2 创建vtp文件 从网络示例和在线文档中,我收集了一些信息,创 ...

  6. PyTorch学习笔记(二)——回归

    PyTorch学习笔记(二)--回归 本文主要是用PyTorch来实现一个简单的回归任务. 编辑器:spyder 1.引入相应的包及生成伪数据 import torch import torch.nn ...

  7. MATLAB学习笔记——二维和三维绘图

    MATLAB学习笔记--二维和三维绘图 近期练习matlab的二维和三维绘图,整理一下,以防忘记. 文章目录 MATLAB学习笔记--二维和三维绘图 一.二维绘图 1.plot命令 2.fplot 命 ...

  8. pythonsze_python学习笔记二 数据类型(基础篇)

    Python基础 对于Python,一切事物都是对象,对象基于类创建 不同类型的类可以创造出字符串,数字,列表这样的对象,比如"koka".24.['北京', '上海', '深圳' ...

  9. 计算鬼成像学习笔记二:二阶关联函数探究

    计算鬼成像学习笔记二:二阶关联函数探究 1 一阶关联函数 2 二阶关联函数 3 二阶关联如何重构物体 4 差分鬼成像关联公式 5 归一化鬼成像关联公式 1 一阶关联函数 一阶关联函数是光场的电场强度之 ...

最新文章

  1. python私有属性怎么定义_Python中私有属性的定义方式
  2. c++ 实现一个object类_说说Object类下面有几种方法呢?
  3. 韩国国税局正调查华为当地分公司 回应称“例行常规审计”
  4. netflix ribbon概述
  5. Boost.Flyweight 复合设计示例
  6. 重学JavaScript深入理解系列(六)
  7. dw1000信标码_DW1000方案工牌型UWB标签,助力10厘米高精度室内定位!
  8. disabling directory browsing
  9. Ubuntu16.04下制作deb包的方法详解
  10. [z] Flare-兼容Memcached协议的分布式(key/value store)键值存储系统
  11. 配置网络策略中的 NAP 条件
  12. [luogu1373]小a和uim之大逃离_动态规划
  13. Python logging日志系统
  14. python读取txt每一行存入数组
  15. CORS基础要点:关于dataType、contentType、withCredentials
  16. 从心理学角度看,如何通过故事影响客户的决策?
  17. iOS常用三方库、插件、知名技术博客、常用开发工具使用介绍等等,大家可以一次性下载了!
  18. mmWave AWR1x Interference Detection - A crucial step to effective mitigation
  19. 电源管理IC临近爆发,详解四大市场趋势
  20. 关于连接数据库出现Connection failed: Access denied for user ‘root‘@‘localhost‘ (using password: YES)解决方案(最有用)

热门文章

  1. 疯狂复习半个月,BAT大厂面试总结
  2. U盘故障:文件或目录损坏且无法读取
  3. 做出详细的生产计划,关键要具备这些条件
  4. Acknowledgement Messages in IBM MQ Series (Websphere MQ)
  5. 关闭Windows Server的IE增强安全配置(ESC)
  6. 使用SpringBoot编写电脑商城项目笔记(每一步都详细记录,前后端数据交互使用html+ajax+json)
  7. 西门子PLC协议网关
  8. 笔记 - 会计学原理
  9. 北大数学韦神又热搜了!随手帮6个博士解决难题:困扰4个月,韦神仅用一天...
  10. 花园植物花卉高清照片合集 Garden photo Pack