Page MenuHomePhabricator

Error in Image example
Closed, ResolvedPublic

Description

See:
http://docs.mitk.org/nightly-qt4/MitkImagePage.html
in Section: "How to get access"
in Example:
// we assume you already have an mitk::Image::Pointer image

try
{

itk::Index<2> idx = {{ 12, 34 }};

mitk::ImagePixelReadAccessor<short,2> readAcces(image, image->GetSliceData(2));
short value = readAccess.GetPixelByIndex(idx);

mitk::ImagePixelWriteAccessor<short,2> writeAccess(image, image->GetSliceData(4));
writeAccess.SetPixelByIndex(idx, 42);

}
catch(mitk::Exception& e)
{

// deal with the situation not to have access

}

This won't work during the error "readAcces" instead of "readAccess" in:
mitk::ImagePixelReadAccessor<short,2> readAcces(image, image->GetSliceData(2));
short value = readAccess.GetPixelByIndex(idx);