当前位置: 首页>>代码示例>>C++>>正文


C++ Pointer::GetImageIO方法代码示例

本文整理汇总了C++中readertype::Pointer::GetImageIO方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetImageIO方法的具体用法?C++ Pointer::GetImageIO怎么用?C++ Pointer::GetImageIO使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在readertype::Pointer的用法示例。


在下文中一共展示了Pointer::GetImageIO方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bool
NrrdPlugin::setFile(QStringList files)
{
  m_fileName = files;
 
  typedef itk::Image<unsigned char, 3> ImageType;
  typedef itk::ImageFileReader<ImageType> ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(m_fileName[0].toAscii().data());

  typedef itk::NrrdImageIO NrrdIOType;
  NrrdIOType::Pointer nrrdIO = NrrdIOType::New();
  reader->SetImageIO(nrrdIO);
  reader->Update();

  itk::ImageIOBase::Pointer imageIO = reader->GetImageIO();

  m_height = imageIO->GetDimensions(0);
  m_width = imageIO->GetDimensions(1);
  m_depth = imageIO->GetDimensions(2);

  m_voxelSizeX = imageIO->GetSpacing(0);
  m_voxelSizeY = imageIO->GetSpacing(1);
  m_voxelSizeZ = imageIO->GetSpacing(2);

  int et = imageIO->GetComponentType();
  if (et == itk::ImageIOBase::UCHAR) m_voxelType = _UChar;
  if (et == itk::ImageIOBase::CHAR) m_voxelType = _Char;
  if (et == itk::ImageIOBase::USHORT) m_voxelType = _UShort;
  if (et == itk::ImageIOBase::SHORT) m_voxelType = _Short;
  if (et == itk::ImageIOBase::INT) m_voxelType = _Int;
  if (et == itk::ImageIOBase::FLOAT) m_voxelType = _Float;

  m_skipBytes = m_headerBytes = 0;

  m_bytesPerVoxel = 1;
  if (m_voxelType == _UChar) m_bytesPerVoxel = 1;
  else if (m_voxelType == _Char) m_bytesPerVoxel = 1;
  else if (m_voxelType == _UShort) m_bytesPerVoxel = 2;
  else if (m_voxelType == _Short) m_bytesPerVoxel = 2;
  else if (m_voxelType == _Int) m_bytesPerVoxel = 4;
  else if (m_voxelType == _Float) m_bytesPerVoxel = 4;

  if (m_4dvol) // do not perform further calculations.
    return true;

  if (m_voxelType == _UChar ||
      m_voxelType == _Char ||
      m_voxelType == _UShort ||
      m_voxelType == _Short)
    {
      findMinMaxandGenerateHistogram();
    }
  else
    {
      findMinMax();
      generateHistogram();
    }

  return true;
}
开发者ID:mdoube,项目名称:drishti,代码行数:61,代码来源:nrrdplugin.cpp

示例2: LoadFile

void MriWatcherGUI::LoadFile(const QString& filename)
{
  ReaderType::Pointer reader = ReaderType::New();
  ImageType::Pointer  image = reader->GetOutput();

  reader->SetFileName( filename.toLatin1().constData() );
  try
    {
    reader->Update();
    }
  catch( itk::ExceptionObject & e )
    {
    // std::cerr << "Exception in file reader " << std::endl;
    // std::cerr << e << std::endl;
    QMessageBox::information( this, "MriWatcher",
                              "Unable to load file:\n" + filename);

    return;
    }

  m_numberofimages++;

  ImageFrameGUI* m_imageframe = new ImageFrameGUI(m_frame);

  connect(m_imageframe->g_imageframe, SIGNAL( Clicked(int) ), this, SLOT( ImageFrameClicked() ) );
  connect(m_imageframe, SIGNAL( GetFiles(const QString &) ), this, SLOT( LoadOverlay(const QString &) ) );

  m_imageframe->g_imageframe->SetManager(&m_imagemanager);
  m_imageframe->g_imageframe->SetSlider(g_slice_slider);
  m_imageframe->g_imageframe->SetId(m_direction);
  QFileInfo info(filename);
  m_imageframe->g_imageframe->SetImageName(info.baseName() );
  m_imageframe->g_imageframe->DrawPosition(g_draw_position->isChecked() );
  m_imageframe->g_imageframe->DrawIntensity(g_draw_intensity->isChecked() );

  // This string should  only be used for display purposes it is not
  // safe to use this for comparison of types
  //  QString pixeltypestring(reader->GetImageIO()->GetComponentTypeInfo().name());
  QString pixeltypestring(QString::fromStdString(reader->GetImageIO()->GetComponentTypeAsString(
                                                   reader->GetImageIO()->GetComponentType() ) ) );
  m_imageframe->g_imageframe->DrawImageName(g_draw_name->isChecked() );

  m_imagesize =  image->GetLargestPossibleRegion().GetSize();
  m_imagespacing = image->GetSpacing();

  int m_cimagesize[3];
  m_cimagesize[0] = m_imagesize[0];
  m_cimagesize[1] = m_imagesize[1];
  m_cimagesize[2] = m_imagesize[2];
  float m_cpixdim[3];
  m_cpixdim[0] = m_imagespacing[0];
  m_cpixdim[1] = m_imagespacing[1];
  m_cpixdim[2] = m_imagespacing[2];

  m_imageframe->g_imageframe->SetImageInfo(m_cimagesize, m_cpixdim, pixeltypestring);
  m_imageframe->g_imageframe->DrawImageInfo(g_draw_info->isChecked() );

  typedef MinimumMaximumImageCalculator<ImageType> CalculatorType;
  CalculatorType::Pointer calculator = CalculatorType::New();
  calculator->SetImage(image);
  calculator->Compute();
  ImageType::PixelType m_min = calculator->GetMinimum();
  ImageType::PixelType m_max = calculator->GetMaximum();
  if( m_max > m_imagemax )
    {
    m_imagemax = m_max;
    }
  if( m_min < m_imagemin )
    {
    m_imagemin = m_min;
    }

  m_imageframe->g_imageframe->SetImageMinMax(m_min, m_max);

  if( m_numberofimages == 1 )
    {
    m_imagemanager.SetSourceImage(image);
    }
  m_imageframe->g_imageframe->SetInputImage(image);
  m_imageframe->g_imageframe->ChangeAlpha(100);

  ReDraw();

  g_slice_slider->setEnabled(true);

  m_frame->setGeometry(QRect(m_frame->x(), m_frame->y(), m_frame->height(), m_frame->width() ) );

  // gridLayout_imageWindows->addWidget(m_imageframe);

  m_imageframelayout->addWidget(m_imageframe);
  m_imageframelist.push_back(m_imageframe);
  // m_imageframe->setLayout(m_imageframelayout);

  m_imageframe->show();
//    g_scrollArea->setWidget(m_imageframe);

  if( m_imageframelist.size() == 1 )
    {
    m_imagemanager.SetCrosshair(m_imagesize[0] / 2, m_imagesize[1] / 2, m_imagesize[2] / 2);
    }
//.........这里部分代码省略.........
开发者ID:NIRALUser,项目名称:MriWatcher,代码行数:101,代码来源:mriwatchergui.cpp


注:本文中的readertype::Pointer::GetImageIO方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。