• 大小: 2.65MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-12
  • 语言: 其他
  • 标签: 图像分割  

资源简介

<>医学图像分割,是由Yuri Y. Boykov和Marie-Pierre Jolly在IEEE发表的。

资源截图

代码片段和文件信息

/*
Copyright (C) 2012 David Doria daviddoria@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation either version 3 of the License or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not see .
*/

#include “ImageGraphCut.h“

// Submodules
#include “Mask/ITKHelpers/Helpers/Helpers.h“
#include “Mask/ITKHelpers/ITKHelpers.h“

#include “itkImage.h“
#include “itkImageFileReader.h“
#include “itkImageFileWriter.h“
#include “itkImageRegionConstIteratorWithIndex.h“
#include “itkVectorImage.h“

int main(int argc char*argv[])
{
  // Verify arguments
  if(argc != 5)
    {
    std::cerr << “Required: image.png foregroundMask.png backgroundMask.png output.png“ << std::endl;
    return EXIT_FAILURE;
    }

  // Parse arguments
  std::string imageFilename = argv[1];

  // This image should have white pixels indicating foreground pixels and be black elsewhere.
  std::string foregroundFilename = argv[2];

  // This image should have white pixels indicating background pixels and be black elsewhere.
  std::string backgroundFilename = argv[3];

  std::string outputFilename = argv[4]; // Foreground/background segment mask

  // Output arguments
  std::cout << “imageFilename: “ << imageFilename << std::endl
            << “foregroundFilename: “ << foregroundFilename << std::endl
            << “backgroundFilename: “ << backgroundFilename << std::endl
            << “outputFilename: “ << outputFilename << std::endl;

  // The type of the image to segment
  typedef itk::VectorImage ImageType;

  // Read the image
  typedef itk::ImageFileReader ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(imageFilename);
  reader->Update();

  // Read the foreground and background stroke images
  Mask::Pointer foregroundMask = Mask::New();
  foregroundMask->ReadFromImage(foregroundFilename);

  Mask::Pointer backgroundMask = Mask::New();
  backgroundMask->ReadFromImage(backgroundFilename);
  
  // Perform the cut
  ImageGraphCut GraphCut;
  GraphCut.SetImage(reader->GetOutput());
  GraphCut.SetNumberOfHistogramBins(20);
  GraphCut.SetLambda(.01);
  std::vector > foregroundPixels = ITKHelpers::GetNonZeroPixels(foregroundMask.GetPointer());
  std::vector > backgroundPixels = ITKHelpers::GetNonZeroPixels(backgroundMask.GetPointer());
  GraphCut.SetSources(foregroundPixels);
  GraphCut.SetSinks(backgroundPixels);
  GraphCut.PerformSegmentation();

  // 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-06-12 15:19  ImageGraphCutSegmentation\
     文件          79  2016-06-12 10:44  ImageGraphCutSegmentation\.gitmodules
     文件        2428  2016-06-12 10:45  ImageGraphCutSegmentation\CMakeLists.txt
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\data\
     文件        1407  2016-06-12 10:40  ImageGraphCutSegmentation\data\background.png
     文件         900  2016-06-12 10:41  ImageGraphCutSegmentation\data\foreground.png
     文件      328509  2016-06-12 10:41  ImageGraphCutSegmentation\data\soldier.png
     文件        2158  2016-06-12 10:41  ImageGraphCutSegmentation\data\soldier_baseline.png
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\Examples\
     文件         182  2016-06-12 10:23  ImageGraphCutSegmentation\Examples\CMakeLists.txt
     文件        3125  2016-06-12 10:24  ImageGraphCutSegmentation\Examples\ImageGraphCutSegmentationExample.cpp
     文件        4551  2016-06-12 10:45  ImageGraphCutSegmentation\ImageGraphCut.h
     文件       17292  2016-06-12 10:46  ImageGraphCutSegmentation\ImageGraphCut.hpp
     文件     2505274  2016-06-12 10:13  ImageGraphCutSegmentation\InteractiveImageGraphCutSegmentation.pdf
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\Kolmogorov\
     文件        8622  2016-06-12 10:31  ImageGraphCutSegmentation\Kolmogorov\block.h
     文件          89  2016-06-12 10:29  ImageGraphCutSegmentation\Kolmogorov\CMakeLists.txt
     文件        2594  2016-06-12 10:31  ImageGraphCutSegmentation\Kolmogorov\graph.cpp
     文件        6215  2016-06-12 10:32  ImageGraphCutSegmentation\Kolmogorov\graph.h
     文件       11602  2016-06-12 10:34  ImageGraphCutSegmentation\Kolmogorov\maxflow.cpp
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\Kolmogorov\Tests\
     文件         265  2016-06-12 10:27  ImageGraphCutSegmentation\Kolmogorov\Tests\CMakeLists.txt
     文件         789  2016-06-12 10:28  ImageGraphCutSegmentation\Kolmogorov\Tests\MaxflowTest.cpp
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\Mask-8a8f2b7\
     文件           6  2012-11-12 23:24  ImageGraphCutSegmentation\Mask-8a8f2b7\.gitignore
     文件          96  2012-11-12 23:24  ImageGraphCutSegmentation\Mask-8a8f2b7\.gitmodules
     文件        2840  2012-11-12 23:24  ImageGraphCutSegmentation\Mask-8a8f2b7\CMakeLists.txt
     目录           0  2016-06-12 15:17  ImageGraphCutSegmentation\Mask-8a8f2b7\ITKHelpers @ d852923\
     文件          31  2012-11-10 05:50  ImageGraphCutSegmentation\Mask-8a8f2b7\ITKHelpers @ d852923\.gitignore
     文件          87  2012-11-10 05:50  ImageGraphCutSegmentation\Mask-8a8f2b7\ITKHelpers @ d852923\.gitmodules
     文件        2374  2012-11-10 05:50  ImageGraphCutSegmentation\Mask-8a8f2b7\ITKHelpers @ d852923\CMakeLists.txt
............此处省略56个文件信息

评论

共有 条评论