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. MVC中验证码的生成

    在项目中验证码的生成通常是需要页面无刷新的,所以验证码图片实际是跟在某个input后面的img,通过控制该img来控制验证码显示的位置,例如: <div> <input id=&qu ...

  2. Quartz.net官方开发指南系列篇

    Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中.它提供了巨大的灵活性而不牺牲 ...

  3. 每天一道LeetCode--371. Sum of Two Integers

    alculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Examp ...

  4. PAT1014——福尔摩斯的约会

    大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”.大侦探很快就明白了,字条 ...

  5. Part 15 Scalar user defined functions in sql server

    Scalar user defined functions in sql server Inline table valued functions in sql server Multi statem ...

  6. 路由器之VPN应用与配置指南

    应用背景 近日,公司需要在外人员通过直接访问连接到公司内网,实现办公等一系列操作,这个时候就需要通过配置路由器VPN实现该需求了. 无线企业路由器可以帮助中小型企业搭建高性价比.稳定的企业办公网络,灵 ...

  7. a href 相对路径 与绝对路径

    <a href="/abc/">内容</a> <a href="abc/">内容</a>的区别,相对路径绝对路径 ...

  8. UI2_UICollectionViewPicture

    // AppDelegate.m // UI2_UICollectionViewPicture // // Created by zhangxueming on 15/7/16. // Copyrig ...

  9. OC7_代理的基本概念

    // // Cat.h // OC7_代理的基本概念 // // Created by zhangxueming on 15/6/24. // Copyright (c) 2015年 zhangxue ...

  10. ubuntu 14.04 下 安装samba 及SSH 服务端的方法

    之前说了 FTP服务器的搭建:http://www.cnblogs.com/bcsflilong/p/4200139.html 今天说一下samba 和ssh服务器的搭建. 先说samba 吧. 在u ...