filter.cpp

来自「A paper that I presented on Supervisory 」· C++ 代码 · 共 64 行

CPP
64
字号
/*!
*  
*
* sharat@mit.edu
*/
#include  <image.h>
#include  <filter.h>
#include <iostream>
#include <fstream>

using namespace std;

/*!
 */
filter::filter(const filter& rhs)
{
  img = cvCloneImage(rhs.img);
}

/*!
 */
filter& filter::operator =(const filter&rhs)
{
  if(&rhs == this)
    return *this;
  if(img)
    cvReleaseImage(&img);
  img = cvCloneImage(rhs.img);
  return *this;
}


/*!
 */
ostream& operator<<(ostream & out,const filter& filt)
{
  CvSize sz = filt.dim();
  out<<sz.height<<" " <<sz.width<<endl;
  /*output dimensions*/
  for(int i=0;i<sz.height;i++)
    {
    for(int j=0;j<sz.width;j++)
      out<<filt[i][j]<<"  ";
    out<<endl;
    }
  return out;
}

/*!
*/
istream& operator>>(istream& in,filter& filt)
{
  int height = 0;
  int width  = 0;
  in >> height >> width;
  /*create the filter*/
  filt = filter(height,width);
  for(int i=0;i<height;i++)
    for(int j=0;j<width;j++)
      in>>filt[i][j];
  return in;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?