You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wheeldetect/3part/Cyclops/include/ImageRegistrator.h

73 lines
2.3 KiB
C

/*!
* \file Registration.cpp
* \date 2019/07/03
*
* \author Lou.Lixuan
* Contact: Lou.Lixuan@hzleaper.com
*
*
* \note
*/
#ifndef ImageRegistrator_h_
#define ImageRegistrator_h_
#include "StdUtils.h"
#include "CVUtils.h"
#include "CyclopsModules.h"
using namespace cv;
struct nifti_image;
struct mat44;
class ImageRegistrator : public ICyclopsModuleInstance
{
/*! \fn setAffineAcce
* Define whether to accelerate rigid affine calculation, default to false
* \fn getAffineAcce
* Get value of whether to accelerate rigid affine calculation
*/
DECLARE_PARAMETER(bool, AffineAcce)
/*! \fn setAccelerate
* Define whether to accelerate nonrigid calculation, default to false
* \fn getAccelerate
* Get value of whether to accelerate nonrigid calculation
*/
DECLARE_PARAMETER(bool, NonRigidAcce)
/*! \fn setNonRigPrecision
* Define precision of nonrigid calculation, 0 to 0.2, default to 0, which influence operation speed significantly
* \fn getNonRigPrecision
* Get value of NonRigPrecision
*/
DECLARE_PARAMETER2(float, NonRigPrecision, 0, 0.201)
public:
ImageRegistrator() : mAffineAcce(false), mNonRigidAcce(false), mNonRigPrecision(0.0) {}
virtual ~ImageRegistrator() {}
//! Smart pointer to hold an instance of CircleDetector
typedef std::shared_ptr<ImageRegistrator> Ptr;
DECL_GET_INSTANCE(ImageRegistrator::Ptr)
/*! registration are performed using affine and non-linear algorithm
* @param refImg input the reference image, data will be changed
* @param floImg input float image, which will Mapping to warped image, data will be changed
* @param affineWarpedImg output image using affine transformation
* @param nonRigidWarpedImg output image using non-rigid transformation
* @param score output score of non_rigid transformation
* @return whether algorithm work properly
*/
virtual bool runRegistration(Mat& refImg, Mat& floImg, Mat* pAffineWarpedImg,
Mat* pNonRigidWarpedImg = nullptr, float* score = nullptr);
protected:
// convert a nifti_image to opencv::mat
void NiftiImage2Mat(nifti_image* niiImage, Mat& dst);
// convert affineMatrix to warpMatrix
void getWarpMat(const mat44& src, Mat& dst, float rescale);
// run nonRigid
float runNonRigid(nifti_image* refNii, nifti_image* floNii, mat44& affineMat, Mat& warpedImg);
};
#endif // ImageRegistrator_h_