MITK Tutorial (三)
Step 2: Use the template with the plugins to read a image
在exampleplugin插件中QmitkAwesomeView.cpp中添加头文件
//Mitk
#include "mitkImageCast.h"
//Itk
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkMeanImageFilter.h"
在DoImageProcessing函数中 修改如下:用ITK::image 从文件中读图 经过中值滤波器处理并转成mitk::image加到DATA note 中
void QmitkAwesomeView::DoImageProcessing()
{
const unsigned int Dimension = 3;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
QList<mitk::DataNode::Pointer> nodes = this->GetDataManagerSelection();
if (nodes.empty()) return;
mitk::DataNode::Pointer node = nodes.front();
if (!node)
{
// Nothing selected. Inform the user and return
QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing.");
return;
}
// here we have a valid mitk::DataNode
// a node itself is not very useful, we need its data item (the image)
mitk::BaseData* data = node->GetData();
if (data)
{
// test if this data item is an image or not (could also be a surface or something totally different)
mitk::Image* image = dynamic_cast<mitk::Image*>( data );
if (image)
{
std::stringstream message;
std::string name;
message << "Performing image processing for image ";
if (node->GetName(name))
{
// a property called "name" was found for this DataNode
message << "'" << name << "'";
}
message << ".";
MITK_INFO << message.str();
// actually do something here...
InputImageType::Pointer inputItkImage = InputImageType::New();
if(image)
{
CastToItkImage( image, inputItkImage );//OK, now you can use inputItkImage whereever you want
cout<<"this is normal itk image!"<<endl;
}
typedef itk::MeanImageFilter<
InputImageType, OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
InputImageType::SizeType indexRadius;
indexRadius[0] = 1; // radius along x
indexRadius[1] = 1; // radius along y
indexRadius[2] = 1;// radius along z
filter->SetRadius( indexRadius );
filter->SetInput( inputItkImage);
filter->Update();
// use the AwesomeImageFilter class from the MyAwesomeLib module
/*AwesomeImageFilter::Pointer awesomeFilter = AwesomeImageFilter::New();
awesomeFilter->SetInput(image);
awesomeFilter->SetOffset(m_Controls.spinboxOffset->value());
awesomeFilter->Update();
std::stringstream outputNodeName;
outputNodeName << node->GetName() << " offset by " << m_Controls.spinboxOffset->value();*/
mitk::Image::Pointer outputImage = mitk::Image::New();
mitk::CastToMitkImage(filter->GetOutput(), outputImage);
mitk::DataNode::Pointer outputNode = mitk::DataNode::New();
outputNode->SetData(outputImage);
outputNode->SetName("1");
this->GetDataStorage()->Add(outputNode);
}
}
MITK Tutorial (三)的更多相关文章
- MITK Tutorial(二)
目标: 生成MITK 插件包括一个新用户交互的视图,并调用一些ITK filters. Step 1: How to create a new MITK Plugin 可以选择用Plugin Gene ...
- MITK Tutorial
MITK 设计来使用模块化和高度的代码重用,既能作为 pure software library或complete application framework.它的结构概览图如下: ITK:提供分 ...
- docker开发实践
一:docker的定义和使用场景: Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VM ...
- scrapy学习笔记一
以前写爬虫都是直接手写获取response然后用正则匹配,被大佬鄙视之后现在决定开始学习scrapy 一.安装 pip install scrapy 二.创建项目 scrapy startprojec ...
- 【OpenGL4.0】GLSL渲染语言入门与VBO、VAO使用:绘制一个三角形 【转】
http://blog.csdn.net/xiajun07061225/article/details/7628146 以前都是用Cg的,现在改用GLSL,又要重新学,不过两种语言很多都是相通的. 下 ...
- 2.3 Hive的数据类型讲解及实际项目中如何使用python脚本对数据进行ETL
一.hive Data Types https://cwiki. apache. org/confluence/display/HiveLanguageManual+Types Numeric Typ ...
- JAVA BIO至NIO演进
主要阐述点: 1.同步/异步 or 阻塞/非阻塞 2.网络模型演进 3.NIO代码示例 一.同步/异步 or 阻塞/非阻塞 同步/异步:核心点在于是否等待结果返回.同步即调用者必须等到结果才返回, ...
- Python Tutorial 学习(三)--An Informal Introduction to Python
3.1. 将Python用作计算器 3.1.1. Numbers 数 作为一个计算器,python支持简单的操作, '+','-','*','/'地球人都知道的加减乘除. ()可以用来改变优先级,同数 ...
- Octave Tutorial(《Machine Learning》)之第三课《数据计算》
第三课 Culculating Data 数据计算 矩阵计算 1.简单的四则运算 2.相乘除,乘方运算(元素位运算) ".*"为对应元素的相乘计算 "./"为对 ...
随机推荐
- Table of Contents - CXF
Getting Started A simple JAX-WS service Writing a service with Spring Tools WSDL to Java RESTful Ser ...
- PLSQL执行sql语句输出的中文是???之解决方法和步骤
方法/步骤 1 登陆plsql,执行sql语句,输出的中文标题显示成问号????:条件包含中文,则无数据输出 步骤阅读 2 输入sql语句select * from V$NLS_PARAMETERS查 ...
- asp.net获取select值的方法
如何使用asp.net获取select值?搜索中发现一个不错的例子,在此与大家分享. 代码: <select runat="server" class="xgxxb ...
- PAT1003——我要通过!
“答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”. 得到“答案正确”的条件是: 1 ...
- Part 59 to 60 Difference between Convert ToString and ToString,String and StringBuilder
Part 59 Difference between Convert ToString and ToString Part 60 Difference between String and Strin ...
- 页面table的每行都有一个<input type='button' />,如何实现点击按钮在按钮下方弹出一个div,点击空白消失
\ <input id="test" type="button" />/*按钮*/ <div id="tanchu"> ...
- Java类加载的时机_4种主动引用会触犯类加载+剩下的被动引用不会触发类的加载
转载自:http://chenzhou123520.iteye.com/blog/1597597 Java虚拟机规范没有强制性约束在什么时候开始类加载过程,但是对于初始化阶段,虚拟机规范则严格规定了有 ...
- Cisco模拟器使用和静态路由配置
一. 模拟器使用 网络拓扑图 1. 模拟器搭建环境及网络结构 2. 使用ios系统加载并配置 3. 加载3745ios后计算pc值以减小cpu的消耗 4. 然后使用CTRL+]+i得到最大的一个值(如 ...
- call与apply函数
call与apply函数 1.为什么需要call与apply函数 Javascript中,每一个函数内部都有一个特殊的关键词this,其随着所处环境的不同其指向也是不同的. 函数的内部其this也是指 ...
- 进程通信---FIFO
管道没有名字,所以只能在具有血缘关系的进程间使用,而在无名管道发展出来的有名管道FIFO,则有路径名与之相关联,以一种特殊设备文件形式存在于文件系统中,从而允许无亲缘关系的进程访问FIFO,下面看FI ...