VTK学习笔记(十二)vtkImageData打印内容

VTK学习笔记(十二)vtkImageData打印内容

std::cout << __FUNCTION__ << std::endl << std::flush;
  volumeData->Print(std::cout);

slicer 默认加载的nii.gz数据类型是int类型,即 int32_t。
在这里插入图片描述

slicer 默认加载的.mhd数据类型是short类型,即 int16_t。

在这里插入图片描述
另外在加载数据时也可以指定加载数据类型。

1、获取数据

之前一直使用 int16_t获取数据,也没有觉得哪里不对,后来一次测试发现,可能获取的数据有误。原因后面,之后我弄明白了会细说。

vtkImageData* volumeData;
int16_t* d_p = (int16_t*)volumeData->GetScalarPointer();

使用int16_t获取的数据,可以看到,中间多了一些“-1”。
在这里插入图片描述

下面是python下simpleITK获取的数据。
在这里插入图片描述

所以使用int32_t才获取到正确的数据。先说一下用int16_t获取到的数据错在哪里,错在了

vtkImageData* volumeData;
int32_t* d_p = (int32_t*)volumeData->GetScalarPointer();

在这里插入图片描述

2、使用前获取数据类型

vtkImageData* volumeData;
int inputDataType = volumeData->GetScalarType();

VTK数据类型

/*--------------------------------------------------------------------------*/
/* Define a unique integer identifier for each native scalar type.  */

/* These types are returned by GetDataType to indicate pixel type.  */
#define VTK_VOID            0
#define VTK_BIT             1
#define VTK_CHAR            2
#define VTK_SIGNED_CHAR    15
#define VTK_UNSIGNED_CHAR   3
#define VTK_SHORT           4
#define VTK_UNSIGNED_SHORT  5
#define VTK_INT             6
#define VTK_UNSIGNED_INT    7
#define VTK_LONG            8
#define VTK_UNSIGNED_LONG   9
#define VTK_FLOAT          10
#define VTK_DOUBLE         11
#define VTK_ID_TYPE        12

VC的stdint.h中数据类型定义

#include <vcruntime.h>

#if _VCRT_COMPILER_PREPROCESSOR

#pragma warning(push)
#pragma warning(disable: _VCRUNTIME_DISABLED_WARNINGS)

typedef signed char        int8_t;
typedef short              int16_t;
typedef int                int32_t;
typedef long long          int64_t;
typedef unsigned char      uint8_t;
typedef unsigned short     uint16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

typedef signed char        int_least8_t;
typedef short              int_least16_t;
typedef int                int_least32_t;
typedef long long          int_least64_t;
typedef unsigned char      uint_least8_t;
typedef unsigned short     uint_least16_t;
typedef unsigned int       uint_least32_t;
typedef unsigned long long uint_least64_t;

typedef signed char        int_fast8_t;
typedef int                int_fast16_t;
typedef int                int_fast32_t;
typedef long long          int_fast64_t;
typedef unsigned char      uint_fast8_t;
typedef unsigned int       uint_fast16_t;
typedef unsigned int       uint_fast32_t;
typedef unsigned long long uint_fast64_t;

typedef long long          intmax_t;
typedef unsigned long long uintmax_t;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落花逐流水

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值