本文整理汇总了C++中DImage::npixels方法的典型用法代码示例。如果您正苦于以下问题:C++ DImage::npixels方法的具体用法?C++ DImage::npixels怎么用?C++ DImage::npixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImage
的用法示例。
在下文中一共展示了DImage::npixels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: estLaplacianNoise
void OpticalFlow::estLaplacianNoise(const DImage& Im1,const DImage& Im2,Vector<double>& para)
{
int nChannels = Im1.nchannels();
if(para.dim()!=nChannels)
para.allocate(nChannels);
else
para.reset();
double temp;
Vector<double> total(nChannels);
for(int k = 0;k<nChannels;k++)
total[k] = 0;
for(int i =0;i<Im1.npixels();i++)
for(int k = 0;k<nChannels;k++)
{
int offset = i*nChannels+k;
temp= abs(Im1.data()[offset]-Im2.data()[offset]);
if(temp>0 && temp<1000000)
{
para[k] += temp;
total[k]++;
}
}
for(int k = 0;k<nChannels;k++)
{
if(total[k]==0)
{
cout<<"All the pixels are invalid in estimation Laplacian noise!!!"<<endl;
cout<<"Something severely wrong happened!!!"<<endl;
para[k] = 0.001;
}
else
para[k]/=total[k];
}
}
示例2: SaveOpticalFlow
bool OpticalFlow::SaveOpticalFlow(const DImage& flow,ofstream& myfile)
{
Image<unsigned short int> foo;
foo.allocate(flow);
for(int i =0;i<flow.npixels();i++)
{
foo.data()[i*2] = (__min(__max(flow.data()[i*2],-200),200)+200)*160;
foo.data()[i*2+1] = (__min(__max(flow.data()[i*2+1],-200),200)+200)*160;
}
return foo.saveImage(myfile);
}
示例3: 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;
}
示例4: showFlow
bool OpticalFlow::showFlow(const DImage& flow,const char* filename)
{
if(flow.nchannels()!=1)
{
cout<<"The flow must be a single channel image!"<<endl;
return false;
}
Image<unsigned char> foo;
foo.allocate(flow.width(),flow.height());
double Max = flow.max();
double Min = flow.min();
for(int i = 0;i<flow.npixels(); i++)
foo[i] = (flow[i]-Min)/(Max-Min)*255;
foo.imwrite(filename);
}