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 (三)的更多相关文章

  1. MITK Tutorial(二)

    目标: 生成MITK 插件包括一个新用户交互的视图,并调用一些ITK filters. Step 1: How to create a new MITK Plugin 可以选择用Plugin Gene ...

  2. MITK Tutorial

      MITK 设计来使用模块化和高度的代码重用,既能作为 pure software library或complete application framework.它的结构概览图如下: ITK:提供分 ...

  3. docker开发实践

    一:docker的定义和使用场景: Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VM ...

  4. scrapy学习笔记一

    以前写爬虫都是直接手写获取response然后用正则匹配,被大佬鄙视之后现在决定开始学习scrapy 一.安装 pip install scrapy 二.创建项目 scrapy startprojec ...

  5. 【OpenGL4.0】GLSL渲染语言入门与VBO、VAO使用:绘制一个三角形 【转】

    http://blog.csdn.net/xiajun07061225/article/details/7628146 以前都是用Cg的,现在改用GLSL,又要重新学,不过两种语言很多都是相通的. 下 ...

  6. 2.3 Hive的数据类型讲解及实际项目中如何使用python脚本对数据进行ETL

    一.hive Data Types https://cwiki. apache. org/confluence/display/HiveLanguageManual+Types Numeric Typ ...

  7. JAVA BIO至NIO演进

    主要阐述点: 1.同步/异步 or  阻塞/非阻塞 2.网络模型演进 3.NIO代码示例 一.同步/异步 or  阻塞/非阻塞 同步/异步:核心点在于是否等待结果返回.同步即调用者必须等到结果才返回, ...

  8. Python Tutorial 学习(三)--An Informal Introduction to Python

    3.1. 将Python用作计算器 3.1.1. Numbers 数 作为一个计算器,python支持简单的操作, '+','-','*','/'地球人都知道的加减乘除. ()可以用来改变优先级,同数 ...

  9. Octave Tutorial(《Machine Learning》)之第三课《数据计算》

    第三课 Culculating Data 数据计算 矩阵计算 1.简单的四则运算 2.相乘除,乘方运算(元素位运算) ".*"为对应元素的相乘计算 "./"为对 ...

随机推荐

  1. PAT (Basic Level) Practise (中文)1027. 打印沙漏(20)

    1027. 打印沙漏(20) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 本题要求你写个程序把给定的符号打印成 ...

  2. Exchange之准备AD及域

    1.         若有旧版本的Exchange 2003,则需要执行以下命令: setup.com /PrepareLegacyExchangePermissions 2.         准备架 ...

  3. iOS - 数组(NSArray)

    1. 数组的常用处理方式 //--------------------不可变数组 //1.数组的创建 NSString *s1 = @"zhangsan"; NSString *s ...

  4. 分享9款用HTML5/CSS3制作的动物人物动画

    1.纯CSS3绘制可爱的蚱蜢 还有眨眼动画 今天我们要分享一个利用纯CSS3绘制的蚱蜢动画,非常可爱. 在线演示 源码下载 2.HTML5 Canvas头发飘逸动画 很酷的HTML5动画 HTML5 ...

  5. Populating Next Right Pointers in Each Node II

    题目地址: https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ 关键思路:讲节点的左右子节 ...

  6. android SDK启动的错误

    1. AVD Manager.exe : failed to execute tools android.bat 请把AVD Manager.exe复制到跟 SDK Manager.exe的相同目录下 ...

  7. 浅析 GRUB 如何加载 linux kernel

    前言 对于 GRUB 的加载流程,网上绝大部分都是写对 menu.lst, grub.cfg 这些 GRUB 配置文件的编写流程,就像是写脚本语言一样,用些关键字就能让 PC机能正确启动桌面 Linu ...

  8. 【Qt】Qt Creator介绍【转】

    简介 Qt Creator是使用Qt开发的IDE.Qt支持Windows.Linux/Unix.Mac OS X.Android.BlackBerry.QNX等多种平台,Qt Creator为不同平台 ...

  9. Nginx+Keepalived实现高可用站点

    Keepalived是一个基于VRRP协议来实现的服务高可用方案,可以利用其来避免IP单点故障,类似的工具还有heartbeat. corosync.pacemaker.但是它一般不会单独出现,而是与 ...

  10. linux 终端显示 -bash-4.1

    解决方法: cp /etc/skel/.bashrc /root/ cp /etc/skel/.bash_profile  /root/ 重新登陆就OK了