本文整理汇总了C++中DImage::matchDimension方法的典型用法代码示例。如果您正苦于以下问题:C++ DImage::matchDimension方法的具体用法?C++ DImage::matchDimension怎么用?C++ DImage::matchDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImage
的用法示例。
在下文中一共展示了DImage::matchDimension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Laplacian
void OpticalFlow::Laplacian(DImage &output, const DImage &input, const DImage& weight)
{
if(output.matchDimension(input)==false)
output.allocate(input);
output.reset();
if(input.matchDimension(weight)==false)
{
cout<<"Error in image dimension matching OpticalFlow::Laplacian()!"<<endl;
return;
}
const _FlowPrecision *inputData=input.data(),*weightData=weight.data();
int width=input.width(),height=input.height();
DImage foo(width,height);
_FlowPrecision *fooData=foo.data(),*outputData=output.data();
// horizontal filtering
for(int i=0;i<height;i++)
for(int j=0;j<width-1;j++)
{
int offset=i*width+j;
fooData[offset]=(inputData[offset+1]-inputData[offset])*weightData[offset];
}
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
{
int offset=i*width+j;
if(j<width-1)
outputData[offset]-=fooData[offset];
if(j>0)
outputData[offset]+=fooData[offset-1];
}
foo.reset();
// vertical filtering
for(int i=0;i<height-1;i++)
for(int j=0;j<width;j++)
{
int offset=i*width+j;
fooData[offset]=(inputData[offset+width]-inputData[offset])*weightData[offset];
}
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)
{
int offset=i*width+j;
if(i<height-1)
outputData[offset]-=fooData[offset];
if(i>0)
outputData[offset]+=fooData[offset-width];
}
}
示例2: genInImageMask
void OpticalFlow::genInImageMask(DImage &mask, const DImage &flow,int interval)
{
int imWidth,imHeight;
imWidth=flow.width();
imHeight=flow.height();
if(mask.matchDimension(flow.width(),flow.height(),1)==false)
mask.allocate(imWidth,imHeight);
else
mask.reset();
const _FlowPrecision *pFlow;
_FlowPrecision *pMask;
pFlow = flow.data();;
pMask=mask.data();
double x,y;
for(int i=0;i<imHeight;i++)
for(int j=0;j<imWidth;j++)
{
int offset=i*imWidth+j;
y=i+pFlow[offset*2+1];
x=j+pFlow[offset*2];
if(x<interval || x>imWidth-1-interval || y<interval || y>imHeight-1-interval)
continue;
pMask[offset]=1;
}
}
示例3: SanityCheck
//--------------------------------------------------------------------------------------------------------
// function to do sanity check: imdx*du+imdy*dy+imdt=0
//--------------------------------------------------------------------------------------------------------
void OpticalFlow::SanityCheck(const DImage &imdx, const DImage &imdy, const DImage &imdt, double du, double dv)
{
if(imdx.matchDimension(imdy)==false || imdx.matchDimension(imdt)==false)
{
cout<<"The dimensions of the derivatives don't match!"<<endl;
return;
}
const _FlowPrecision* pImDx,*pImDy,*pImDt;
pImDx=imdx.data();
pImDy=imdy.data();
pImDt=imdt.data();
double error=0;
for(int i=0;i<imdx.height();i++)
for(int j=0;j<imdx.width();j++)
for(int k=0;k<imdx.nchannels();k++)
{
int offset=(i*imdx.width()+j)*imdx.nchannels()+k;
double temp=pImDx[offset]*du+pImDy[offset]*dv+pImDt[offset];
error+=fabs(temp);
}
error/=imdx.nelements();
cout<<"The mean error of |dx*u+dy*v+dt| is "<<error<<endl;
}
示例4: LoadOpticalFlow
bool OpticalFlow::LoadOpticalFlow(ifstream& myfile,DImage& flow)
{
Image<unsigned short int> foo;
if(foo.loadImage(myfile) == false)
return false;
if(!flow.matchDimension(foo))
flow.allocate(foo);
for(int i = 0;i<flow.npixels();i++)
{
flow.data()[i*2] = (double)foo.data()[i*2]/160-200;
flow.data()[i*2+1] = (double)foo.data()[i*2+1]/160-200;
}
return true;
}
示例5: warpFL
void OpticalFlow::warpFL(DImage &warpIm2, const DImage &Im1, const DImage &Im2, const DImage &Flow)
{
if(warpIm2.matchDimension(Im2)==false)
warpIm2.allocate(Im2.width(),Im2.height(),Im2.nchannels());
ImageProcessing::warpImageFlow(warpIm2.data(),Im1.data(),Im2.data(),Flow.data(),Im2.width(),Im2.height(),Im2.nchannels());
}