Exemplo n.º 1
0
Descriptor ColorStructure::extract_(MyImage *image,
				   bool makeVisRep,
				   Magick::Image *repr){
  cv::Mat &img = *image->getOpenCVMat();
  Frame* frame = new Frame(img);
  XM::ColorStructureDescriptor *ehd = Mpeg7Feature::getColorStructureD(frame, 64);
  Descriptor desc;
  for(size_t i = 0; i < ehd->GetSize(); ++i)
    desc.push_back((float) ehd->GetElement(i));
  return desc;
}
Exemplo n.º 2
0
Descriptor ScalableColor::extract_(MyImage *image,
				   bool makeVisRep,
				   Magick::Image *repr){
  cv::Mat &img = *image->getOpenCVMat();
  Frame* frame = new Frame(img);
  const size_t dsize = 256;
  XM::ScalableColorDescriptor *scd = Mpeg7Feature::getScalableColorD(frame, true, dsize);
  Descriptor desc;
  for(size_t i = 0; i < dsize; ++i)
    desc.push_back((float) scd->GetCoefficient(i));
  return desc;
}
Exemplo n.º 3
0
Descriptor EdgeHistogram::extract_(MyImage *image,
				   bool makeVisRep,
				   Magick::Image *repr){
  cv::Mat &img = *image->getOpenCVMat();
  Frame* frame = new Frame(img);
  XM::EdgeHistogramDescriptor *ehd_ = Mpeg7Feature::getEdgeHistogramD(frame);
  XM::EHD *ehd = ehd_->GetEdgeHistogram();
  Descriptor desc;
  for(int i = 0; i < 80; ++i)
    desc.push_back((float) ehd->Local_Edge[i]);
  return desc;
}
Exemplo n.º 4
0
Descriptor ColorLayout::extract_(MyImage *image,
				 bool makeVisrep,
				 Magick::Image *repr){
  cv::Mat &img = *image->getOpenCVMat();
  Frame *frame = new Frame(img);
  XM::ColorLayoutDescriptor *xmdesc = 
    Mpeg7Feature::getColorLayoutD(frame);
  size_t nY = xmdesc->GetNumberOfYCoeff();
  size_t nC = xmdesc->GetNumberOfCCoeff();
  int *YCoeff  = xmdesc->GetYCoeff();
  int *CbCoeff = xmdesc->GetCbCoeff();
  int *CrCoeff = xmdesc->GetCrCoeff();

  // write coefficients to single descriptor
  Descriptor desc;
  for(size_t i = 0; i < nY; i++)
    desc.push_back((float) YCoeff[i]);
  for(size_t i = 0; i < nC; i++)
    desc.push_back((float) CbCoeff[i]);
  for(size_t i = 0; i < nC; i++)
    desc.push_back((float) CrCoeff[i]);
  return desc;
}
Exemplo n.º 5
0
Descriptor HomogeneousTexture::extract_(MyImage *image,
					bool makeVisrep,
					Magick::Image *repr){
  cv::Mat non_gray = *image->getOpenCVMat();
  cv::Mat img = Mat( non_gray.rows, non_gray.cols, CV_8UC1);
  cvtColor(non_gray, img, CV_BGR2GRAY);
  Frame *frame = new Frame(img.rows, img.cols, false, true, false);
  frame->setGray(img);
  XM::HomogeneousTextureDescriptor *xmdesc = 
    Mpeg7Feature::getHomogeneousTextureD(frame, true);
  Descriptor desc;
  for(int i = 0; i < 62; ++i)
    desc.push_back((float) xmdesc->feature[i]);
  delete xmdesc;
  return desc;
}
Exemplo n.º 6
0
Descriptor DominantColor::extract_(MyImage *image,
				   bool makeVisRep,
				   Magick::Image *repr){
  cv::Mat &img = *image->getOpenCVMat();
  Frame* frame = new Frame(img);
  XM::DominantColorDescriptor *dcd = 
    Mpeg7Feature::getDominantColorD( frame , false ); // don't normalize
  size_t nColors = dcd->GetDominantColorsNumber();
  XM::DOMCOL *colors = dcd->GetDominantColors();
  cout << "we've got: " << nColors << " dominant colors" << endl;
  Descriptor desc;
  for(size_t i = 0; i < nColors; ++i){
    cout << "color " << i << "  percentage: " << colors[i].m_Percentage;
    for(size_t j = 0; j < 3; ++j){
      cout << " " <<  j << " " << colors[i].m_ColorValue[j];
      desc.push_back((float) colors[i].m_ColorValue[j]);
    } // for j
    cout << endl;
  } // for i
  desc.resize(24, 0.0);
  return desc;
}