static bool CompareImages(mitk::Image::Pointer mitkImage, cv::Mat openCVImage)
{
  float equal = true;
  if (static_cast<int>(mitkImage->GetDimension(0)) != openCVImage.cols || static_cast<int>(mitkImage->GetDimension(1)) != openCVImage.rows)
  {
    equal = false;
  }
  mitk::ImagePixelReadAccessor<float,2> imageAcces(mitkImage, mitkImage->GetSliceData(0));
  for(int i=0; i<openCVImage.cols; i++)
  {
    for(int j=0; j<openCVImage.rows; j++)
    {
      itk::Index<2> currentIndex;
      currentIndex[0] = i;
      currentIndex[1] = j;
      float mitkImageValue = imageAcces.GetPixelByIndex(currentIndex);
      float openCVImageValue = openCVImage.at<float>(j,i);
      if (!mitk::Equal(mitkImageValue,openCVImageValue))
      {
        equal = false;
      }
    }
  }
  return equal;
}
Ejemplo n.º 2
0
static bool CompareImages(mitk::Image::Pointer image1, mitk::Image::Pointer image2)
{
  //check if epsilon is exceeded
  unsigned int sliceDimension = image1->GetDimension(0)*image1->GetDimension(1);
  bool picturesEqual = true;

  float* floatArray1 = (float*)image1->GetSliceData(0, 0, 0)->GetData();
  float* floatArray2 = (float*)image2->GetSliceData(0, 0, 0)->GetData();
  for(unsigned int i = 0; i < sliceDimension; i++)
  {
    if(!(mitk::Equal(floatArray1[i], floatArray2[i])))
    {
      picturesEqual = false;
    }
  }
  return picturesEqual;
}
Ejemplo n.º 3
0
 void ToFOpenCVImageGrabber::MapScalars( mitk::Image::Pointer mitkImage, IplImage* openCVImage)
 {
   unsigned int numOfPixel = m_ImageGrabber->GetCaptureWidth()*m_ImageGrabber->GetCaptureHeight();
   float* floatData = (float*)mitkImage->GetSliceData(0, 0, 0)->GetData();
   vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction = vtkColorTransferFunction::New();
   vtkSmartPointer<vtkFloatArray> floatArrayInt;
   floatArrayInt = vtkFloatArray::New();
   floatArrayInt->Initialize();
   floatArrayInt->SetArray(floatData, numOfPixel, 0);
   mitk::ScalarType min = mitkImage->GetScalarValueMin();
   mitk::ScalarType max = mitkImage->GetScalarValueMaxNoRecompute();
   MITK_INFO<<"Minimum: "<<min;
   MITK_INFO<<"Maximum: "<<max;
   colorTransferFunction->RemoveAllPoints();
   colorTransferFunction->AddRGBPoint(min, 0, 0, 0);
   colorTransferFunction->AddRGBPoint(max, 1, 1, 1);
   colorTransferFunction->SetColorSpaceToHSV();
   //TODO other depth values
   colorTransferFunction->MapScalarsThroughTable(floatArrayInt, (unsigned char*)openCVImage->imageData, VTK_LUMINANCE);
 }
Ejemplo n.º 4
0
void ReadPixel(mitk::PixelType, mitk::Image::Pointer image, itk::Index<3> indexPoint, double& value)
{
  if (image->GetDimension() == 2)
  {
    mitk::ImagePixelReadAccessor<PixelType,2> readAccess(image, image->GetSliceData(0));
    itk::Index<2> idx;
    idx[0] = indexPoint[0];
    idx[1] = indexPoint[1];
    value = readAccess.GetPixelByIndex(idx);
  }
  else if (image->GetDimension() == 3)
  {
    mitk::ImagePixelReadAccessor<PixelType,3> readAccess(image, image->GetVolumeData(0));
    itk::Index<3> idx;
    idx[0] = indexPoint[0];
    idx[1] = indexPoint[1];
    idx[2] = indexPoint[2];
    value = readAccess.GetPixelByIndex(idx);
  }
  else
  {
    //unhandled
  }
}