本文整理汇总了C++中ImageFeature类的典型用法代码示例。如果您正苦于以下问题:C++ ImageFeature类的具体用法?C++ ImageFeature怎么用?C++ ImageFeature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageFeature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void add(ImageFeature &a, const ImageFeature &b, const uint z) {
for(uint x=0;x<a.xsize();++x) {
for(uint y=0;y<a.ysize();++y) {
a(x,y,z)+=b(x,y,0);
}
}
}
示例2: fft
ImageFeature fft(const ImageFeature &img) {
ImageFeature result(img.xsize(),img.ysize(),2);
#ifdef HAVE_FFT_LIBRARY
fftw_complex FIMG[img.xsize()][img.ysize()];
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
FIMG[x][y].re=img(x,y,0);
FIMG[x][y].im=0;
}
}
fftwnd_plan plan = fftw2d_create_plan(img.xsize(),img.ysize(), FFTW_FORWARD, FFTW_ESTIMATE | FFTW_IN_PLACE);
fftwnd_one(plan,&FIMG[0][0],NULL);
fftwnd_destroy_plan(plan);
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
result(x,y,0)=FIMG[x][y].re;
result(x,y,1)=FIMG[x][y].im;
}
}
#else
#warning "FFT is used without FFT library enabled."
ERR << "FFT not available, thus returning empty image instead of fourier transformed version. All that comes now is probably bogus." << endl;
#endif
return result;
}
示例3: toVector
vector<double> toVector(const ImageFeature &image) {
vector<double> result(image.size());
for(uint i=0;i<image.size();++i) {
result[i]=image[i];
}
return result;
}
示例4: shift
void shift(ImageFeature &img, const double offset) {
for(uint c=0;c<img.zsize();++c) {
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
img(x,y,c)+=offset;
}}}
}
示例5: equalize
//default values for fact_eq and offset are set in imagelib.hpp.... by paredes
void equalize(ImageFeature &image, uint wndsize, double bnd, uint c, double fact_eq, uint offset) {
double fact_orig=1.0-fact_eq;
int xdim=image.xsize();
int ydim=image.ysize();
int i,j,xini,xend,yini,yend;
ImageFeature acu(xdim,ydim,1);
ImageFeature divisor(xdim,ydim,1);
for(i=0; i < int(ydim-wndsize); i+=offset) {
yini = i;
yend = i+wndsize;
for(j=0; j < int(xdim-wndsize); j+=offset) {
xini = j;
xend = j+wndsize;
eq_histo(xini,xend,yini,yend,image,c,acu,divisor);
}
}
for(j=0; j < ydim; j++) {
for(i=0; i < xdim; i++) {
if ( (image(i,j,c) > bnd) && (divisor(i,j,0) > 0.0) ) {
image(i,j,c)=fact_eq*(acu(i,j,0)/divisor(i,j,0)) + fact_orig*image(i,j,c); // weighted average between original and equalized image
}
}
}
}
示例6: extractPatches
void LocalFeatureExtractor::extractPatches(ImageFeature &img, const ::std::vector<FeatureExtractionPosition> &positions, LocalFeatures &lf) {
if(settings_.padding>0) {
img=zeropad(img,settings_.padding, settings_.padding);
}
lf.winsize_=settings_.winsize;
lf.padding_=settings_.padding;
lf.numberOfFeatures_=positions.size();
lf.zsize_=img.zsize();
int windiameter=2*settings_.winsize+1;
lf.dim_=windiameter*windiameter*img.zsize();
lf.imageSizeX_=img.xsize();
lf.imageSizeY_=img.ysize();
lf.filename_=img.filename();
int savesize=settings_.winsize*2+1;
lf.positions_=positions;
lf.data_.resize(positions.size());
for(uint i=0;i<positions.size();++i) {
const FeatureExtractionPosition &pos=positions[i];
ImageFeature p=getPatch(img,pos.x,pos.y,pos.s);
if(uint(pos.s)!=settings_.winsize) {
p=scale(p,savesize,savesize);
}
lf.data_[i]=toVector(p);
}
}
示例7: efficientLocalMean
double efficientLocalMean(const int x,const int y,const int k,const ImageFeature &laufendeSumme) {
int k2=k/2;
int dimx=laufendeSumme.xsize();
int dimy=laufendeSumme.ysize();
//wanting average over area: (y-k2,x-k2) ... (y+k2-1, x+k2-1)
int starty=y-k2;
int startx=x-k2;
int stopy=y+k2-1;
int stopx=x+k2-1;
if(starty<0) starty=0;
if(startx<0) startx=0;
if(stopx>dimx-1) stopx=dimx-1;
if(stopy>dimy-1) stopy=dimy-1;
double unten, links, oben, obenlinks;
if(startx-1<0) links=0;
else links=laufendeSumme(startx-1,stopy,0);
if(starty-1<0) oben=0;
else oben=laufendeSumme(stopx,starty-1,0);
if((starty-1 < 0) || (startx-1 <0)) obenlinks=0;
else obenlinks=laufendeSumme(startx-1,starty-1,0);
unten=laufendeSumme(stopx,stopy,0);
// cout << "obenlinks=" << obenlinks << " oben=" << oben << " links=" << links << " unten=" <<unten << endl;
int counter=(stopy-starty+1)*(stopx-startx+1);
return (unten-links-oben+obenlinks)/counter;
}
示例8: gammaCorrection
void gammaCorrection(ImageFeature &img, double gamma) {
for(uint c=0;c<img.zsize();++c) {
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
img(x,y,c)=exp(gamma*log(img(x,y,c)));
}
}
}
}
示例9: absolute
void absolute(ImageFeature &img1) {
for (uint z = 0; z < img1.zsize(); z++)
for (uint x = 0; x < img1.xsize(); x++)
for (uint y = 0; y < img1.ysize(); y++) {
if (img1(x, y, z) < 0.0) {
img1(x, y, z) = -img1(x, y, z);
}
}
}
示例10: divide
void divide(ImageFeature &a, const double &d) {
for(uint x=0;x<a.xsize();++x) {
for(uint y=0;y<a.ysize();++y) {
for(uint z=0;z<a.zsize();++z) {
a(x,y,z)/=d;
}
}
}
}
示例11: multiply
void multiply(ImageFeature &img, const double s) {
for(uint z=0;z<img.zsize();++z) {
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
img(x,y,z)*=s;
}
}
}
}
示例12: rect
void rect(ImageFeature &img, const uint x, const uint y, const uint w, const uint h, const ::std::vector<double> &color, bool dash) {
uint dashCounterMax = 3;
uint dashCounter = dashCounterMax;
uint dashMode = 1;
// upper line
for(uint i = x; i < x + w; ++i) {
dashCounter--;
if (dashCounter == 0) {
dashCounter = dashCounterMax;
dashMode = 1 - dashMode;
}
for(uint c = 0; c < img.zsize(); ++c) {
if (!dash || (dashMode == 1)) {
img(i, y, c) = color[c];
}
}
}
// right line
for(uint i = y; i < y + h; ++i) {
dashCounter--;
if (dashCounter == 0) {
dashCounter = dashCounterMax;
dashMode = 1 - dashMode;
}
for(uint c = 0; c < img.zsize(); ++c) {
if (!dash || (dashMode == 1)) {
img(x + w - 1, i, c) = color[c];
}
}
}
// lower line
for(int i = x + w - 1; i >= (int) x; --i) {
dashCounter--;
if (dashCounter == 0) {
dashCounter = dashCounterMax;
dashMode = 1 - dashMode;
}
for(uint c = 0; c < img.zsize(); ++c) {
if (!dash || (dashMode == 1)) {
img(i, y + h - 1, c)=color[c];
}
}
}
// left line
for(int i = y + h - 1; i >= (int) y; --i) {
dashCounter--;
if (dashCounter == 0) {
dashCounter = dashCounterMax;
dashMode = 1 - dashMode;
}
for(uint c = 0; c < img.zsize(); ++c) {
if (!dash || (dashMode == 1)) {
img(x, i, c) = color[c];
}
}
}
}
示例13: ImageFeature
ImageFeature DifferenceOfGaussian::difference(const ImageFeature& img1, const ImageFeature& img2) {
ImageFeature newImage = ImageFeature(img1.xsize(), img1.ysize(), 1);
for (int x = 0; x < (int) newImage.xsize(); x++) {
for (int y = 0; y < (int) newImage.ysize(); y++) {
newImage(x, y, 0) = img1(x, y, 0) - img2(x, y, 0);
}
}
return newImage;
}
示例14: maximum
double maximum(const ImageFeature &img, uint c) {
double max=-1.0;
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
max=::std::max(max,img(x,y,c));
}
}
return max;
}
示例15: minimum
double minimum(const ImageFeature &img, uint c) {
double min=numeric_limits<double>::max();
for(uint x=0;x<img.xsize();++x) {
for(uint y=0;y<img.ysize();++y) {
min=::std::min(min,img(x,y,c));
}
}
return min;
}