Newer
Older
Eric Wait
committed
#include "MexCommand.h"
#include "CudaProcessBuffer.cuh"
Eric Wait
committed
void MexNormalizedCovariance::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] )
Eric Wait
committed
{
int device = 0;
if (nrhs>2)
device = mat_to_c((int)mxGetScalar(prhs[2]));
Vec<size_t> imageDims1, imageDims2;
HostPixelType* imageIn1, * imageIn2;
Eric Wait
committed
CudaProcessBuffer cudaBuffer(device);
setupImagePointers(prhs[0],&imageIn1,&imageDims1);
setupImagePointers(prhs[1],&imageIn2,&imageDims2);
if (imageDims1!=imageDims2)
mexErrMsgTxt("Image Dimensions Must Match!\n");
double normCoVar = cudaBuffer.normalizedCovariance(imageIn1,imageIn2,imageDims1);
plhs[0] = mxCreateDoubleScalar(normCoVar);
}
std::string MexNormalizedCovariance::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] )
Eric Wait
committed
{
if (nrhs!=3)
return "Incorrect number of inputs!";
if (nlhs!=1)
return "Requires one output!";
// if (!mxIsUint8(prhs[0]) || !mxIsUint8(prhs[1]))
// return "Images has to be formated as a uint8!";
Eric Wait
committed
size_t numDims = mxGetNumberOfDimensions(prhs[0]);
if (numDims>3 || numDims<2)
return "Image can only be either 2D or 3D!";
numDims = mxGetNumberOfDimensions(prhs[1]);
if (numDims>3 || numDims<2)
return "Image can only be either 2D or 3D!";
if (!mxIsDouble(prhs[2]))
return "Factor needs to be a double!";
return "";
}
Eric Wait
committed
{
return "normalizedCovariance = CudaMex('NormalizedCovariance',imageIn1,imageIn2,[device]);";
}
Eric Wait
committed
{
std::string msg = "\tThis will calculate how similar the images are to one another.\n";
msg += "\tThe return value will be between [-1,1]. Where 1 is exactly the same and -1 is exactly the opposite.\n";
msg += "\tImages must match in dimension.\n";
msg += "\n";
return msg;
}