[ITK-users] Buffered Region out of Range error

Michael Jackson mike.jackson at bluequartz.net
Wed Oct 28 07:57:44 EDT 2015


Nope. It does not help. I’m going to add some more information and see where that takes the discussion. We are trying to integrate ITK into our project DREAM.3D (github.com/dream3d <http://github.com/dream3d>) which uses a plugin system to load user developed data analysis filters. The failure mode we are seeing is when 2 filters, in different plugins, use the same ITK code. The DREAM.3D plugin that contains the DREAM.3D Filter that gets loaded first will run through without issues. The second DREAM.3D Plugin that contains the second DREAM.3D Filter will fail with the exception message. The ITK code is exactly the same except for the name of the c++ class that holds the code. We have replicated this on OS X 10.9 and 10.10. We can NOT replicate the issue on Windows (VS2013) or Linux (Clang 3.6). We have it down to a fairly simple DREAM.3D test case but not an ITK test case. After moving some codes around and moving some of our looping code inside the “try-catch” block we finally started seeing the exception messages. I am hoping we are just using ITK incorrectly and OS X is just exposing the incorrect use. The weird part is that we get the correct results on the other systems so it is not like the other platforms have a silent failure.

Thanks for any help.
--
Mike Jackson  [mike.jackson at bluequartz.net]


> On Oct 27, 2015, at 6:22 PM, Matt McCormick <matt.mccormick at kitware.com> wrote:
> 
> Hi Mike,
> 
> Does calling
> 
>  UpdateLargestPossibleRegion()
> 
> instead of
> 
>  Update()
> 
> help?
> 
> Matt
> 
> On Tue, Oct 27, 2015 at 5:59 PM, Michael Jackson
> <mike.jackson at bluequartz.net> wrote:
>> I have been struggling with this error all afternoon and I just can not “see” what I am doing wrong. I am getting the following exception message from our program:
>> 
>> Failed to execute itk::SignedMaurerDistanceMapImage filter for Feature 9. Error Message returned from ITK:
>>   itk::ERROR: MultiThreader(0x7fb53486e200): Exception occurred during SingleMethodExecute
>> /Users/Shared/DREAM3D_SDK/InsightToolkit-4.7.2/Modules/Core/Common/include/itkImageConstIterator.h:211:
>> itk::ERROR: Region ImageRegion (0x12e6f6730)
>>  Dimension: 3
>>  Index: [0, 0, 0]
>>  Size: [64, 64, 4]
>> is outside of buffered region ImageRegion (0x7fb53c0a8040)
>>  Dimension: 3
>>  Index: [0, 0, 0]
>>  Size: [0, 0, 0]
>> 
>> So what are the reasons that this can happen? Basically we creating an unsigned char image where we fill in the pixels, then run the  Itk filter on each unsigned char image. Finally we want to copy the final output data into one of our own arrays. I will post the code under here. Any help is greatly appreciated.
>> 
>> size_t iDims[3] = { 0, 0, 0 };
>>  float origin[3] = { 0.0f, 0.0f, 0.0f };
>>  float resolution[3] = { 0.0f, 0.0f, 0.0f };
>> 
>>  image->getDimensions(iDims);
>>  image->getOrigin(origin);
>>  image->getResolution(resolution);
>> 
>>  int32_t numFeatures = m_SignedDistanceFields.size();
>> 
>>  typedef itk::Image<unsigned char, 3> BoolImageType;
>>  typedef itk::Image<float, 3> FloatImageType;
>>  std::vector<BoolImageType::Pointer> booleanFeatureImages(numFeatures);
>>  BoolImageType::IndexType start;
>>  BoolImageType::SizeType size;
>>  BoolImageType::RegionType region;
>> 
>>  start.Fill(0);
>> 
>>  size[0] = iDims[0];
>>  size[1] = iDims[1];
>>  size[2] = iDims[2];
>> 
>>  region.SetIndex(start);
>>  region.SetSize(size);
>> 
>>  for (int32_t i = 0; i < numFeatures; i++)
>>  {
>>    BoolImageType::Pointer tmpBoolImage = BoolImageType::New();
>>    tmpBoolImage->SetRegions(region);
>>    tmpBoolImage->Allocate();
>>    tmpBoolImage->SetOrigin(origin);
>>    tmpBoolImage->SetSpacing(resolution);
>>    tmpBoolImage->FillBuffer(0);
>>    booleanFeatureImages[i] = tmpBoolImage;
>>  }
>> 
>>  size_t zStride = 0;
>>  size_t yStride = 0;
>>  size_t index = 0;
>> 
>>  for (size_t z = 0; z < iDims[2]; z++)
>>  {
>>    zStride = z * iDims[1] * iDims[2];
>>    for (size_t y = 0; y < iDims[1]; y++)
>>    {
>>      yStride = y * iDims[0];
>>      for (size_t x = 0; x < iDims[0]; x++)
>>      {
>>        index = zStride + yStride + x;
>>        BoolImageType::IndexType pixelIndex;
>>        pixelIndex[0] = x;
>>        pixelIndex[1] = y;
>>        pixelIndex[2] = z;
>>        if (x == y && y == z) { booleanFeatureImages[0]->SetPixel(pixelIndex, 255); }
>>        booleanFeatureImages[m_FeatureIds[index]]->SetPixel(pixelIndex, 255);
>>      }
>>    }
>>  }
>>  // Compute signed distance field for each Feature
>>  typedef itk::SignedMaurerDistanceMapImageFilter<BoolImageType, FloatImageType> SignedMaurerFilter;
>> 
>>  for (int32_t i = 0; i < numFeatures; i++)
>>  {
>>    if (getCancel() == true) { return; }
>>    SignedMaurerFilter::Pointer signedDistMap = SignedMaurerFilter::New();
>>    float* tmpDistField = m_SignedDistanceFields[i].lock()->getPointer(0);
>>    signedDistMap->SetInsideIsPositive(false);
>>    signedDistMap->SetSquaredDistance(true);
>>    signedDistMap->SetUseImageSpacing(true);
>>    signedDistMap->SetInput(booleanFeatureImages[i]);
>>    try
>>    {
>>      signedDistMap->Update();
>> 
>>      for (size_t z = 0; z < iDims[2]; z++)
>>      {
>>        zStride = z * iDims[1] * iDims[2];
>>        for (size_t y = 0; y < iDims[1]; y++)
>>        {
>>          yStride = y * iDims[0];
>>          for (size_t x = 0; x < iDims[0]; x++)
>>          {
>>            index = zStride + yStride + x;
>>            BoolImageType::IndexType pixelIndex;
>>            pixelIndex[0] = x;
>>            pixelIndex[1] = y;
>>            pixelIndex[2] = z;
>>            FloatImageType::Pointer out = signedDistMap->GetOutput();
>>            out->SetBufferedRegion(region);
>>            tmpDistField[index] = out->GetPixel(pixelIndex);
>>          }
>>        }
>>      }
>>    }
>>    catch (itk::ExceptionObject& err)
>>    {
>>      setErrorCondition(-5);
>>      QString ss = QObject::tr("Failed to execute itk::SignedMaurerDistanceMapImage filter for Feature %1. Error Message returned from ITK:\n   %2").arg(i).arg(err.GetDescription());
>>      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
>>    }
>>  }
>> --
>> Mike Jackson
>> BlueQuartz Software, LLC
>> [e]: mike.jackson at bluequartz.net
>> 
>> _____________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20151028/073903f1/attachment.html>


More information about the Insight-users mailing list