NifTK
16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
|
Public Types | |
typedef mitk::GenericProperty < itk::Matrix< float, 4, 4 > > | MatrixProperty |
Public Member Functions | |
Undistortion (const mitk::DataNode::Pointer &node) | |
Undistortion (const mitk::Image::Pointer &image) | |
virtual | ~Undistortion () |
virtual void | Run (const mitk::DataNode::Pointer &output) |
virtual void | Run (const mitk::Image::Pointer &output) |
void | PrepareOutput (mitk::Image::Pointer &output) |
Static Public Member Functions | |
static void | LoadIntrinsicCalibration (const std::string &filename, mitk::DataNode::Pointer node) |
static void | LoadIntrinsicCalibration (const std::string &filename, const mitk::Image::Pointer &img) |
static void | LoadStereoRig (const std::string &filename, mitk::DataNode::Pointer node) |
static void | LoadStereoRig (const std::string &filename, mitk::Image::Pointer img) |
static bool | NeedsToLoadIntrinsicCalib (const std::string &filename, const mitk::DataNode::Pointer &node) |
static bool | NeedsToLoadIntrinsicCalib (const std::string &filename, const mitk::Image::Pointer &image) |
static bool | NeedsToLoadStereoRigExtrinsics (const std::string &filename, const mitk::DataNode::Pointer &node) |
static bool | NeedsToLoadStereoRigExtrinsics (const std::string &filename, const mitk::Image::Pointer &image) |
static void | CopyImagePropsIfNecessary (const mitk::DataNode::Pointer source, mitk::Image::Pointer target) |
Copies properties from node to image, if they don't already exist on the image. More... | |
Static Public Attributes | |
static const char * | s_ImageIsUndistortedPropertyName = "niftk.ImageIsUndistorted" |
static const char * | s_CameraCalibrationPropertyName = "niftk.CameraCalibration" |
static const char * | s_ImageIsRectifiedPropertyName = "niftk.ImageIsRectified" |
static const char * | s_StereoRigTransformationPropertyName = "niftk.StereoRigTransformation" |
Protected Member Functions | |
void | ValidateInput () |
virtual void | Process (const IplImage *input, IplImage *output, bool recomputeCache) |
Static Protected Member Functions | |
static bool | NeedsToLoadImageProperty (const std::string &fileName, const std::string &propertyName, const mitk::Image::Pointer &image) |
Protected Attributes | |
mitk::DataNode::Pointer | m_Node |
mitk::Image::Pointer | m_Image |
mitk::CameraIntrinsics::Pointer | m_Intrinsics |
IplImage * | m_MapX |
IplImage * | m_MapY |
bool | m_RecomputeCache |
Idea is to create one of these Undistortion objects for a given DataNode or Image, which then does all the magic for computing the undistortion and caches some data. Output, however, is not tied into an instance of the class. Instead it's passed into Run().
How to use. You can pass in any combination of input DataNode or Image and output DataNode or Image. 1) For exmaple: mitk::DataNode::Pointer input = ...; mitk::DataNode::Pointer output = mitk::DataNode::New(); niftk::Undistortion* undist = new niftk::Undistortion(input); undist->Run(output);
2) Another one: mitk::Image::Pointer input = ...; mitk::Image::Pointer output; niftk::Undistortion* undist = new niftk::Undistortion(input); undist->PrepareOutput(output); undist->Run(output);
Either way, the node or image need to have calibration properties. The output object will have these calibrations copied to it as well, including s_ImageIsUndistortedPropertyName. In case both node and its attached image have calibration props then image wins. Also, for consistency sake, both calibration props need to match in this case.
A note about smart pointers: various functions take as parameter something like const mitk::DataNode::Pointer&. This means that the smart-pointer itself is const but the pointed-to object is not! Const is not transitive for smart-pointers! Using const smart-pointers avoids unnecessary ref-count operations (which make stepping through the code rather annoying). If you wanted a const pointed-to object then the parameter would be mitk::DataNode::ConstPointer.
When I wrote this originally, I decided for a non-mitk-smartypants class here, i.e. bare-bones c++ class. Now I can't remember why. Feel free to change it to mitk.
typedef mitk::GenericProperty<itk::Matrix<float, 4, 4> > niftk::Undistortion::MatrixProperty |
niftk::Undistortion::Undistortion | ( | const mitk::DataNode::Pointer & | node | ) |
niftk::Undistortion::Undistortion | ( | const mitk::Image::Pointer & | image | ) |
std::runtime_error | if image.IsNull() |
|
virtual |
|
static |
Copies properties from node to image, if they don't already exist on the image.
|
static |
|
static |
|
static |
|
static |
|
staticprotected |
|
static |
|
static |
|
static |
|
static |
void niftk::Undistortion::PrepareOutput | ( | mitk::Image::Pointer & | output | ) |
You should call this if you use Run(const mitk::Image::Pointer&). If output is null then a new image is allocated. If the dimensions of an existing image are wrong then a new one is allocated too.
std::runtime_error | rethrown from ValidateInput() |
|
protectedvirtual |
FIXME: presumably this is virtual so that we could derive a gpu version. but then the ipl parameters are no use!
recomputeCache | true image dimensions or type have changed, m_RecomputeCache is passed in (and set to false afterwards, by Run()). |
exceptions | if anything is wrong. |
|
virtual |
stuff | from ValidateInput(). |
std::runtime_error | if output is null. |
std::runtime_error | if the attached image is zero-size. |
|
virtual |
output has to have the same size as input (which you passed in to the constructor). Call PrepareOutput() to make sure.
|
protected |
Check that we have an image to work on, it has the correct depth/channels, etc.
std::runtime_error | if image type is wrong or required properties are missing. |
std::runtime_error | if image is zero-size. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
static |
|
static |
|
static |