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


C++ itk::ImageRegion类代码示例

本文整理汇总了C++中itk::ImageRegion的典型用法代码示例。如果您正苦于以下问题:C++ ImageRegion类的具体用法?C++ ImageRegion怎么用?C++ ImageRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: imageIndices

typename MaskedHistogramGenerator<TBinValue, TQuadrantProperties>::HistogramType MaskedHistogramGenerator<TBinValue, TQuadrantProperties>::ComputeMaskedScalarImageHistogram
    (const TImage* const image, const itk::ImageRegion<2>& imageRegion,
     const Mask* const mask, const itk::ImageRegion<2>& maskRegion, const unsigned int numberOfBins,
     const TRangeValue& rangeMin, const TRangeValue& rangeMax, const bool allowOutside, const HoleMaskPixelTypeEnum& maskValue)
{
  std::vector<itk::Index<2> > maskIndices = ITKHelpers::GetPixelsWithValueInRegion(mask, maskRegion, maskValue);

  // Compute the corresponding locations in the imageRegion
  std::vector<itk::Index<2> > imageIndices(maskIndices.size());
  itk::Offset<2> maskRegionToImageRegionOffset = imageRegion.GetIndex() - maskRegion.GetIndex(); // The offset from the maskRegion to the imageRegion
  for(size_t i = 0; i < maskIndices.size(); ++i)
  {
    imageIndices[i] = maskIndices[i] + maskRegionToImageRegionOffset;
  }

  HistogramType histogram;

  // Get this channels masked scalar values
  std::vector<typename TImage::PixelType> validPixels =
      ITKHelpers::GetPixelValues(image, imageIndices);

  // Compute the histogram of the scalar values
  if(allowOutside)
  {
    histogram = HistogramGeneratorType::ScalarHistogramAllowOutside(validPixels, numberOfBins, rangeMin, rangeMax);
  }
  else
  {
    histogram = HistogramGeneratorType::ScalarHistogram(validPixels, numberOfBins, rangeMin, rangeMax);
  }

  return histogram;
}
开发者ID:daviddoria,项目名称:Histogram,代码行数:33,代码来源:MaskedHistogramGenerator.hpp

示例2: maskIterator

void Mask::ApplyRegionToImageRegion(const itk::ImageRegion<2>& maskRegion, TImage* const image,
                                    const itk::ImageRegion<2>& imageRegion, const typename TImage::PixelType& color) const
{
  if(maskRegion.GetSize() != imageRegion.GetSize())
    {
    std::cerr << "imageRegion and maskRegion must be the same size!" << std::endl
              << "Image region: " << imageRegion << std::endl
              << "Mask region: " << maskRegion << std::endl;
    return;
    }

  itk::ImageRegionConstIterator<Mask> maskIterator(this, maskRegion);
  itk::ImageRegionIterator<TImage> imageIterator(image, imageRegion);

  while(!maskIterator.IsAtEnd())
  {
    if(this->IsHole(maskIterator.GetIndex()))
    {
      imageIterator.Set(color);
    }

    ++maskIterator;
    ++imageIterator;
  }
}
开发者ID:badrobit,项目名称:RGBD-Inpainting,代码行数:25,代码来源:DepthMask.hpp

示例3: GetRandomPixelInRegion

itk::Index<2> GetRandomPixelInRegion(const itk::ImageRegion<2>& region)
{
    itk::Index<2> pixel;
    pixel[0] = region.GetIndex()[0] + Helpers::RandomInt(0, region.GetSize()[0] - 1);
    pixel[1] = region.GetIndex()[1] + Helpers::RandomInt(0, region.GetSize()[1] - 1);

    return pixel;
}
开发者ID:daviddoria,项目名称:PatchMatch,代码行数:8,代码来源:PatchMatchHelpers.cpp

示例4: GetRegionCenter

itk::Index<2> GetRegionCenter(const itk::ImageRegion<2>& region)
{
  // This assumes that the region is an odd size in both dimensions
  itk::Index<2> center;
  center[0] = region.GetIndex()[0] + region.GetSize()[0] / 2;
  center[1] = region.GetIndex()[1] + region.GetSize()[1] / 2;

  return center;
}
开发者ID:daviddoria,项目名称:TempRepo,代码行数:9,代码来源:ITKHelpers.cpp

示例5: GetRandomRegionInRegion

itk::ImageRegion<2> GetRandomRegionInRegion(const itk::ImageRegion<2>& region, const unsigned int patchRadius)
{
    itk::Index<2> randomPixel;
    randomPixel[0] = Helpers::RandomInt(region.GetIndex()[0], region.GetIndex()[0] + region.GetSize()[0]);
    randomPixel[1] = Helpers::RandomInt(region.GetIndex()[1], region.GetIndex()[1] + region.GetSize()[1]);

    itk::ImageRegion<2> randomRegion = ITKHelpers::GetRegionInRadiusAroundPixel(randomPixel, patchRadius);

    return randomRegion;
}
开发者ID:daviddoria,项目名称:PatchMatch,代码行数:10,代码来源:PatchMatchHelpers.cpp

示例6: GetPixelsWithValueInRegion

std::vector<itk::Offset<2> > Mask::GetHoleOffsetsInRegion(itk::ImageRegion<2> region) const
{
  // Ensure the region is inside the image
  region.Crop(this->GetLargestPossibleRegion());

  std::vector<itk::Index<2> > indices =
      GetPixelsWithValueInRegion(this, region, HoleMaskPixelTypeEnum::HOLE);

  std::vector<itk::Offset<2> > holeOffsets =
      IndicesToOffsets(indices, region.GetIndex());

  return holeOffsets;
}
开发者ID:badrobit,项目名称:RGBD-Inpainting,代码行数:13,代码来源:DepthMask.cpp

示例7: InitializeVTKImage

void InitializeVTKImage(const itk::ImageRegion<2>& region, const unsigned int channels, vtkImageData* outputImage)
{
  // Setup and allocate the VTK image
  outputImage->SetDimensions(region.GetSize()[0],
                             region.GetSize()[1],
                             1);
  outputImage->AllocateScalars(VTK_UNSIGNED_CHAR, channels);
}
开发者ID:daviddoria,项目名称:ITKVTKHelpers,代码行数:8,代码来源:ITKVTKHelpers.cpp

示例8: assert

float TruncatedQuadraticDifference<TImage>::Difference
(const TImage* const image, const float truncationPoint, const itk::ImageRegion<2>& region1, const itk::ImageRegion<2>& region2)
{
  assert(region1.GetSize() == region2.GetSize());
  assert(image->GetLargestPossibleRegion().IsInside(region1));
  assert(image->GetLargestPossibleRegion().IsInside(region2));

  itk::ImageRegionConstIterator<TImage> patch1Iterator(image, region1);
  itk::ImageRegionConstIterator<TImage> patch2Iterator(image, region2);

  float sumSquaredDifferences = 0;

  typename TImage::PixelType pixel1;
  typename TImage::PixelType pixel2;

  while(!patch1Iterator.IsAtEnd())
    {
    pixel1 = patch1Iterator.Get();
    pixel2 = patch2Iterator.Get();

    float squaredDifference = PixelDifferences::SumOfSquaredDifferences(pixel1, pixel2);

//       std::cout << "Source pixel: " << static_cast<unsigned int>(sourcePixel)
//                 << " target pixel: " << static_cast<unsigned int>(targetPixel)
//                 << "Difference: " << difference << " squaredDifference: " << squaredDifference << std::endl;

    // Perform the truncation
    if(sqrt(squaredDifference) > truncationPoint)
    {
      squaredDifference = truncationPoint*truncationPoint;
    }

    sumSquaredDifferences += squaredDifference;

    ++patch1Iterator;
    ++patch2Iterator;
    } // end while iterate over sourcePatch


  unsigned int numberOfPixels = region1.GetNumberOfPixels();

  float averageSSD = sumSquaredDifferences / static_cast<float>(numberOfPixels);

  return averageSSD;
}
开发者ID:daviddoria,项目名称:PatchComparison,代码行数:45,代码来源:TruncatedQuadraticDifference.hpp

示例9: SetRegion

void PatchHighlighter::SetRegion(const itk::ImageRegion<2>& region)
{
  // Snap user patch to integer pixels
  double position[3];
  position[0] = region.GetIndex()[0];
  position[1] = region.GetIndex()[1];
  position[2] = 0;

  this->PatchLayer.ImageSlice->SetPosition(position);
}
开发者ID:nocnokneo,项目名称:PatchBasedInpainting,代码行数:10,代码来源:PatchHighlighter.cpp

示例10: SetRegionCenterPixel

void SetRegionCenterPixel(vtkImageData* const image, const itk::ImageRegion<2>& region, const unsigned char color[3])
{
  int dims[3];
  image->GetDimensions(dims);

  unsigned char* pixel = static_cast<unsigned char*>(image->GetScalarPointer(region.GetIndex()[0] + region.GetSize()[0]/2,
                                                                             region.GetIndex()[1] + region.GetSize()[1]/2, 0));
  pixel[0] = color[0];
  pixel[1] = color[1];
  pixel[2] = color[2];
  pixel[3] = 255; // visible
}
开发者ID:daviddoria,项目名称:ITKVTKHelpers,代码行数:12,代码来源:ITKVTKHelpers.cpp

示例11: assert

void LocalPCADistance<TImage>::ComputeProjectionMatrix(const itk::ImageRegion<2>& region)
{
  assert(this->Image);

  // Dilate the query region
  itk::Index<2> dilatedRegionCorner = {{region.GetIndex()[0] - 1, region.GetIndex()[1] - 1}};
  itk::Size<2> dilatedRegionSize = {{region.GetSize()[0] + 2, region.GetSize()[1] + 2}};
  itk::ImageRegion<2> dilatedRegion(dilatedRegionCorner, dilatedRegionSize);
  dilatedRegion.Crop(this->Image->GetLargestPossibleRegion());

  // Compute a local feature matrix (the query patch and all of it's neighbors (if they are inside the image)
  MatrixType featureMatrix = PatchProjection<Eigen::MatrixXf, Eigen::VectorXf>::
                               VectorizeImage(this->Image, region.GetSize()[0]/2, dilatedRegion);

  unsigned int inputPoints = featureMatrix.cols();

  this->ProjectionMatrix = PatchProjection<MatrixType, VectorType>::ProjectionMatrixFromFeatureMatrix(featureMatrix, this->MeanVector);

  // Only keep the number of columns corresponding to the number of input points used
  this->ProjectionMatrix = EigenHelpers::TruncateColumns<MatrixType>(this->ProjectionMatrix, inputPoints);
}
开发者ID:daviddoria,项目名称:PatchComparison,代码行数:21,代码来源:LocalPCADistance.hpp

示例12: PatchHighlighter

void BasicViewerWidget<TImage>::slot_UpdateSource(const itk::ImageRegion<2>& sourceRegion)
{
//  std::cout << "BasicViewerWidget::slot_UpdateSource " << sourceRegion << std::endl;

  if(!this->SourceHighlighter)
  {
    this->SourceHighlighter = new PatchHighlighter(sourceRegion.GetSize()[0]/2, this->Renderer, Qt::green);
  }
  this->SourceHighlighter->SetRegion(sourceRegion);

  QImage sourceImage = ITKQtHelpers::GetQImageColor(this->Image.GetPointer(), sourceRegion);
  QGraphicsPixmapItem* item = this->SourcePatchScene->addPixmap(QPixmap::fromImage(sourceImage));
  gfxSource->fitInView(item);

  // Make the renderer show the Highlighter in the new position
  this->qvtkWidget->GetRenderWindow()->Render();
}
开发者ID:SXYJerry,项目名称:PatchBasedInpainting,代码行数:17,代码来源:BasicViewerWidget.hpp

示例13: BlankRegion

void BlankRegion(vtkImageData* image, const itk::ImageRegion<2>& region)
{
  // Blank the image
  for(unsigned int i = region.GetIndex()[0]; i < region.GetIndex()[0] + region.GetSize()[0]; ++i)
    {
    for(unsigned int j = region.GetIndex()[1]; j < region.GetIndex()[1] + region.GetSize()[1]; ++j)
      {
      unsigned char* pixel = static_cast<unsigned char*>(image->GetScalarPointer(i, region.GetIndex()[1], 0));
      pixel[0] = 0;
      pixel[1] = 0;
      pixel[2] = 0;
      pixel[3] = 0; // transparent
      }
    }
  image->Modified();
}
开发者ID:daviddoria,项目名称:ITKVTKHelpers,代码行数:16,代码来源:ITKVTKHelpers.cpp

示例14: operator

 bool operator()(const itk::ImageRegion<2> region1, const itk::ImageRegion<2> region2) const
 {
   return IndexCompareFunctor(region1.GetIndex(), region2.GetIndex());
 }
开发者ID:SXYJerry,项目名称:PatchBasedInpainting,代码行数:4,代码来源:LidarHSVTextureGradient.hpp

示例15: assert

void ManualPatchSelectionDialog<TImage>::slot_UpdateResult(const itk::ImageRegion<2>& sourceRegion,
                                                           const itk::ImageRegion<2>& targetRegion)
{
  assert(sourceRegion.GetSize() == targetRegion.GetSize());

  if(!this->Image->GetLargestPossibleRegion().IsInside(sourceRegion))
  {
    std::cerr << "Source region is outside the image!" << std::endl;
    return;
  }
  
  QImage qimage(sourceRegion.GetSize()[0], sourceRegion.GetSize()[1], QImage::Format_RGB888);

  if(MaskImage->CountHolePixels(sourceRegion) > 0)
  {
    //std::cerr << "The source patch must not have any hole pixels!" << std::endl;
    //btnAccept->setVisible(false);
    qimage.fill(Qt::green);
  }
  else
  {
    typename TImage::Pointer tempImage = TImage::New();
    ITKHelpers::ConvertTo3Channel(this->Image, tempImage.GetPointer());
    if(this->Image->GetNumberOfComponentsPerPixel() != 3)
      {
      ITKHelpers::ScaleAllChannelsTo255(tempImage.GetPointer());
      }

    itk::ImageRegionIterator<TImage> sourceIterator(tempImage, sourceRegion);
    itk::ImageRegionIterator<TImage> targetIterator(tempImage, targetRegion);
    itk::ImageRegionIterator<Mask> maskIterator(MaskImage, targetRegion);

    typename TImage::Pointer resultPatch = TImage::New();
    resultPatch->SetNumberOfComponentsPerPixel(Image->GetNumberOfComponentsPerPixel());
    itk::ImageRegion<2> resultPatchRegion;
    resultPatchRegion.SetSize(sourceRegion.GetSize());
    resultPatch->SetRegions(resultPatchRegion);
    resultPatch->Allocate();

    while(!maskIterator.IsAtEnd())
      {
      ITKHelpers::FloatVectorImageType::PixelType pixel;

      if(MaskImage->IsHole(maskIterator.GetIndex()))
        {
        pixel = sourceIterator.Get();
        }
      else
        {
        pixel = targetIterator.Get();
        }

      itk::Offset<2> offset = sourceIterator.GetIndex() - sourceRegion.GetIndex();
      itk::Index<2> offsetIndex;
      offsetIndex[0] = offset[0];
      offsetIndex[1] = offset[1];
      resultPatch->SetPixel(offsetIndex, pixel);

      ++sourceIterator;
      ++targetIterator;
      ++maskIterator;
      } // end iterator loop

    qimage = ITKQtHelpers::GetQImageColor(resultPatch.GetPointer(), resultPatch->GetLargestPossibleRegion());
  } // end else

  this->ResultPatchScene->clear();
  QGraphicsPixmapItem* item = this->ResultPatchScene->addPixmap(QPixmap::fromImage(qimage));
  gfxResult->fitInView(item);

}
开发者ID:nocnokneo,项目名称:PatchBasedInpainting,代码行数:71,代码来源:ManualPatchSelectionDialog.hpp


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