基于itk的医学图像处理程序

  • p1_353240
    了解作者
  • 3.6KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-01 03:25
    上传日期
本处理程序功能不多,只是为了完成本人实验所需的部分,去噪,减背景值,中值滤波,伪彩色,融合; 欢迎和大家交流
ImageProcess.rar
  • imageprocess.h
    986B
  • imageprocess.cpp
    18.1KB
内容介绍
#include "imageprocess.h" #include "qmessagebox.h" #include <qfiledialog.h> #include <QMouseEvent> #include <QPainter> #include <stdio.h> #include <fstream> #include <iostream> #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkMedianImageFilter.h" #include "itkImageRegionIterator.h" #include "itkTIFFImageIO.h" #include "itkIntensityWindowingImageFilter.h" #include "itkRGBPixel.h" #include "itkCustomColormapFunction.h" #include "itkScalarToRGBColormapImageFilter.h" #include "itkMersenneTwisterRandomVariateGenerator.h" using namespace std; ImageProcess::ImageProcess(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); //original = false; //Medfilter = false; //Substract = false; //Process = false; //Fusion = false; } void ImageProcess::on_pushButton_Luminescence_clicked() { filename = QFileDialog::getOpenFileName(this, tr("选择图像"), "", tr("Images(*.tif)")); if (filename.isEmpty()) { return; } else { imgMouse = new QImage; if (!(imgMouse->load(filename))) //加载图像 { QMessageBox::information(this, tr("打开图像失败"), tr("打开图像失败!")); delete imgMouse; return; } newImgMouse = imgMouse->scaled(ui.label_Luminescence->width(), ui.label_Luminescence->height()); ui.label_Luminescence->setPixmap(QPixmap::fromImage(newImgMouse)); } //original = true; //Medfilter = false; //Substract = false; //Process = false; //Fusion = false; } void ImageProcess::on_pushButton_Photography_clicked() { QString filenamePhotography; filenamePhotography = QFileDialog::getOpenFileName(this, tr("选择图像"), "", tr("Images(*.tif)")); if (filenamePhotography.isEmpty()) { return; } else { QImage* img = new QImage; if (!(img->load(filenamePhotography))) //加载图像 { QMessageBox::information(this, tr("打开图像失败"), tr("打开图像失败!")); delete img; return; } QImage newImg = img->scaled(ui.label_Photography->width(), ui.label_Photography->height()); ui.label_Photography->setPixmap(QPixmap::fromImage(newImg)); } } void ImageProcess::on_pushButton_Medfilter_clicked() { QByteArray ba = filename.toLatin1(); const char *c_str2 = ba.data(); typedef unsigned short PixelType; const unsigned int Dimension = 2; typedef itk::Image< PixelType, Dimension > ImageType; typedef itk::ImageFileReader< ImageType > ReaderType; typedef itk::ImageFileWriter< ImageType > WriterType; ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); reader->SetFileName(c_str2); filename = "..\\Image\\Medfilter_image.tif"; writer->SetFileName("..\\Image\\Medfilter_image.tif"); reader->SetImageIO(itk::TIFFImageIO::New()); reader->Update(); ImageType::Pointer inputImage = ImageType::New(); inputImage = reader->GetOutput(); typedef itk::MedianImageFilter< ImageType, ImageType > FilterType; FilterType::Pointer filter = FilterType::New(); ReaderType::SizeType indexRadius; QString txt = ui.lineEdit_Medfilter->text(); int size = txt.toInt(); int Radius_size = (size - 1) / 2; indexRadius[0] = Radius_size; indexRadius[1] = Radius_size; filter->SetRadius(indexRadius); filter->SetInput(inputImage); writer->SetInput(filter->GetOutput()); writer->SetImageIO(itk::TIFFImageIO::New()); try { writer->Update(); } catch (itk::ExceptionObject & err) { QMessageBox::warning(NULL, QString("warning"), QString("Eerr!!! ExceptionObject caught !")); } QImage *img = new QImage; img->load("..\\Image\\Medfilter_image.tif"); QImage newImg = img->scaled(ui.label_Luminescence->width(), ui.label_Luminescence->height()); ui.label_Luminescence->setPixmap(QPixmap::fromImage(newImg)); //original = false; //Medfilter = true; //Substract = false; //Process = false; //Fusion = false; } void ImageProcess::on_pushButton_Substract_clicked() { QByteArray ba = filename.toLatin1(); const char *c_str2 = ba.data(); typedef unsigned short PixelType; const unsigned int Dimension = 2; typedef itk::Image< PixelType, Dimension > ImageType; typedef itk::ImageFileReader< ImageType > ReaderType; typedef itk::ImageFileWriter< ImageType > WriterType; ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); reader->SetFileName(c_str2); filename = "..\\Image\\Substract_image.tif"; writer->SetFileName("..\\Image\\Substract_image.tif"); reader->SetImageIO(itk::TIFFImageIO::New()); reader->Update(); ImageType::Pointer input_Medfilter_image = ImageType::New(); input_Medfilter_image = reader->GetOutput(); typedef itk::ImageRegionIterator<ImageType> ItType; ItType it(input_Medfilter_image, input_Medfilter_image->GetRequestedRegion()); it.GoToBegin(); while (!it.IsAtEnd()) { ImageType::PixelType value = it.Get(); QString txt = ui.lineEdit_Substract->text(); int number = txt.toInt(); int set_value = 0; if (value > number) set_value = value - number; else set_value = 0; it.Set(set_value); ++it; } writer->SetInput(input_Medfilter_image); writer->SetImageIO(itk::TIFFImageIO::New()); try { writer->Update(); } catch (itk::ExceptionObject & err) { //std::cerr << "ExceptionObject caught !" << std::endl; //std::cerr << err << std::endl; QMessageBox::warning(NULL, QString("warning"), QString("err!!! ExceptionObject caught !")); } QImage *img = new QImage; img->load("..\\Image\\Substract_image.tif"); QImage newImg = img->scaled(ui.label_Luminescence->width(), ui.label_Luminescence->height()); ui.label_Luminescence->setPixmap(QPixmap::fromImage(newImg)); //original = false; //Medfilter = false; //Substract = true; //Process = false; //Fusion = false; } void ImageProcess::on_pushButton_Process_clicked() { QByteArray ba = filename.toLatin1(); const char *c_str2 = ba.data(); typedef unsigned short PixelType; const unsigned int Dimension = 2; typedef itk::Image< PixelType, Dimension > ImageType; typedef itk::ImageFileReader< ImageType > ReaderType; typedef itk::ImageFileWriter< ImageType > WriterType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(c_str2); reader->SetImageIO(itk::TIFFImageIO::New()); reader->Update();; ImageType::Pointer inputImage = ImageType::New(); inputImage = reader->GetOutput(); typedef itk::IntensityWindowingImageFilter <ImageType, ImageType> IntensityWindowingImageFilterType; IntensityWindowingImageFilterType::Pointer filter = IntensityWindowingImageFilterType::New(); filter->SetInput(inputImage); int Value_Min = ui.lineEdit_Low->text().toInt(); int Value_Max = ui.lineEdit_High->text().toInt(); filter->SetWindowMinimum(Value_Min); filter->SetWindowMaximum(Value_Max); filter->SetOutputMinimum(0); filter->SetOutputMaximum(256); filter->Update(); typedef itk::RGBPixel<unsigned char> RGBPixelType; typedef itk::Image<RGBPixelType, 2> RGBImageType; typedef itk::ScalarToRGBColormapImageFilter<ImageType, RGBImageType> RGBFilterType; RGBFilterType::Pointer rgbfilter = RGBFilterType::New(); rgbfilter->SetInput(filter->GetOutput()); rgbfilter->SetColormap(RGBFilterType::Jet); { typedef itk::ImageFileWriter< RGBImageType > WriterType; WriterType::Pointer writer = WriterType::New(); writer->SetFileName("..\\Image\\Process.tif"); writer->SetImageIO(itk::TIFFImageIO::New()); writer->SetInput(rgbfilter->GetOutput()); writer->Update(); } filenameProcess = "..\\Image\\Process.tif"; QImage *ProccessImage = new QImage; ProccessImage->load("..\\Image\\Process.tif"); QImage newImg = ProccessImage->scaled(ui.label_Luminescence->width(), ui.label_Luminescence->height()); ui.label_Luminescence->setPixmap(QPixmap::fromImage(newImg)); //original = false; //
评论
    相关推荐
    • 数字图像处理
      HSI RGB LZW 哈弗慢编码,直方图均衡化,累计直方图,灰度映射,腐蚀,膨胀(文件内容:图像处理练习.doc 数字图像处理代码.doc)
    • 数字图像处理
      本书是数字图像处理理论与实践相结合的成功之作,强调理论用于解决工业或科学研究中常见的实际问题。这种与基本概念和数字图像处理的各种实用技术,使读者能用这些技术解决数字图像中的新问题。 全书共22章,1-5章...
    • 数字图像处理
      本书全面系统地讲述了数字图像处理领域中的15大核心话题,包括色彩空间、图像编码、频域变换、图像文件格式、几何变换、灰度变换、图像的增强处理、边缘检测、轮廓跟踪、形态学处理、图像分割、图像的加密与隐藏、...
    • 数字图像处理
      数字图像处理宝典,PDF高清版,因每次上传限制,分为7个部分上传,搜索时搜 “数字图像处理(中午版part#)
    • 图像处理论文
      这是一篇本人发表的文章,里面详细写了对于处理多峰值图像处理的新思想,这种思想可以解决小图像,多峰阈值分割问题。
    • 图像处理
      图像处理
    • 图像处理
      图像处理
    • 图像处理
      图像处理
    • 图像处理
      图像处理
    • 图像处理代码
      这个是图像处理不可多得的源码,是我们做项目时用到的所有技术。涉及到哈夫曼码编码、香农-弗诺编码、伪彩色、滤波、模板匹配 、图像平滑、图像复原、图像显示、特征提取、图像变、运动检测、小波变换、图像分割等...