当前位置: 首页>>代码示例>>C++>>正文


C++ image::empty方法代码示例

本文整理汇总了C++中image::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ image::empty方法的具体用法?C++ image::empty怎么用?C++ image::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在image的用法示例。


在下文中一共展示了image::empty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setImage

void pMenu::setImage(const image &image) {
  if(image.empty() == false) {
    GtkImage *gtkImage = CreateImage(image, true);
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
  } else {
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
  }
}
开发者ID:johnwchadwick,项目名称:gcmtools,代码行数:8,代码来源:menu.cpp

示例2: setImage

void pImage::setImage(const image &image) {
  qtLabel->setPixmap(QPixmap());

  if(!image.empty()) {
    QPixmap pixmap = CreatePixmap(image);
    qtLabel->setPixmap(pixmap);
    qtLabel->setMinimumSize(pixmap.width(), pixmap.height());
  }
}
开发者ID:johnwchadwick,项目名称:gcmtools,代码行数:9,代码来源:image.cpp

示例3: setImage

void pListView::setImage(unsigned selection, unsigned position, const image& image) {
  GtkTreeModel* model = gtk_tree_view_get_model(GTK_TREE_VIEW(subWidget));
  GtkTreeIter iter;
  gtk_tree_model_get_iter_from_string(model, &iter, string(selection));
  if(image.empty() == false) {
    GdkPixbuf* pixbuf = CreatePixbuf(image, true);
    gtk_list_store_set(store, &iter, 1 + position * 2, pixbuf, -1);
  } else {
    gtk_list_store_set(store, &iter, 1 + position * 2, nullptr, -1);
  }
}
开发者ID:Brunnis,项目名称:bsnes-mercury,代码行数:11,代码来源:list-view.cpp

示例4: getMax

  bool brightRGB::getMax(const image& img,dvector& dest) const{

    // image empty?
    if (img.empty()) {
      setStatusString("image empty");
      dest.resize(0);
      return false;
    }

    const rgbPixel transColor = getParameters().transColor;
    ivector maxV(3,-1);
    image::const_iterator it = img.begin();
    if(getParameters().transparent) {
      while(it != img.end()) {
	if(*it != transColor) {
	  if((*it).getRed() > maxV.at(0))
	    maxV.at(0) = (*it).getRed();
	  if((*it).getGreen() > maxV.at(1))
	    maxV.at(1) = (*it).getGreen();
	  if((*it).getBlue() > maxV.at(2))
	    maxV.at(2) = (*it).getBlue();
	}
	it++;
      }
      // only transparent pixels?
      if (maxV.at(0)==-1) {
        setStatusString("only transparent pixels");
        dest.resize(0);
        return false;
      }
    } else { // no transparent color
      while(it != img.end()) {
	if((*it).getRed() > maxV.at(0))
	  maxV.at(0) = (*it).getRed();
	if((*it).getGreen() > maxV.at(1))
	  maxV.at(1) = (*it).getGreen();
	if((*it).getBlue() > maxV.at(2))
	  maxV.at(2) = (*it).getBlue();
	it++;
      }
    }
    if(maxV.at(0) == -1)
      return false;
    dest.castFrom(maxV);
    // normalize to 0..1
    dest.divide(255);
    return true;
  };
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:48,代码来源:ltiBrightRGB.cpp

示例5: preprocess

void preprocess(const image<float> &img,
                const image<float> &mean,
                int width,
                int height,
                vec_t *dst) {
  image<float> resized = resize_image(img, width, height);

  image<> resized_uint8(resized);

  if (!mean.empty()) {
    image<float> normalized = subtract_scalar(resized, mean);
    *dst                    = normalized.to_vec();
  } else {
    *dst = resized.to_vec();
  }
}
开发者ID:dreadlord1984,项目名称:tiny-cnn,代码行数:16,代码来源:caffe_converter.cpp

示例6: append

void pTabFrame::append(string text, const image& image) {
  unsigned selection = tabFrame.state.text.size() - 1;

  Tab tab;
  tab.child = gtk_fixed_new();
  tab.container = gtk_hbox_new(false, 0);
  tab.image = gtk_image_new();
  tab.title = gtk_label_new(text);
  tabs.append(tab);

  gtk_widget_show(tab.child);
  gtk_widget_show(tab.container);
  gtk_widget_show(tab.image);
  gtk_widget_show(tab.title);
  gtk_box_pack_start(GTK_BOX(tab.container), tab.image, false, false, 0);
  gtk_box_pack_start(GTK_BOX(tab.container), tab.title, false, false, 2);

  gtk_notebook_append_page(GTK_NOTEBOOK(gtkWidget), tab.child, tab.container);
  setFont(widget.state.font);
  if(!image.empty()) setImage(selection, image);
}
开发者ID:apollolux,项目名称:hello-phoenix,代码行数:21,代码来源:tab-frame.cpp

示例7: append

void pTabFrame::append(string text, const image& image) {
  unsigned selection = tabFrame.state.text.size() - 1;
  qtTabFrame->addTab(new QWidget, QString::fromUtf8(text));
  if(!image.empty()) setImage(selection, image);
}
开发者ID:Brunnis,项目名称:bsnes-mercury,代码行数:5,代码来源:tab-frame.cpp

示例8: getMedian

  bool brightRGB::getMedian(const image& img,dvector& dest) const{


    // image empty?
    if (img.empty()) {
      setStatusString("image empty");
      dest.resize(0);
      return false;
    }

    const rgbPixel transColor = getParameters().transColor;
    dest.resize(3);
    ivector hist0(256,0);
    ivector hist1(256,0);
    ivector hist2(256,0);
    image::const_iterator it = img.begin();
    if(getParameters().transparent) {
      while(it != img.end()) {
  	if(*it != transColor) {
	  ++hist0.at((*it).getRed());
	  ++hist1.at((*it).getGreen());
	  ++hist2.at((*it).getBlue());
	}
	it++;
      }
      const int counterHalf = hist0.sumOfElements()/2;
      // check for complete image transparent
      if (counterHalf==0) {
        setStatusString("only transparent pixels");
        dest.resize(0);
        return false;
      }

      int i,s;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist0.at(i);
      }
      dest.at(0) = i-1;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist1.at(i);
      }
      dest.at(1) = i-1;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist2.at(i);
      }
      dest.at(2) = i-1;
    } else { // no transparent color
      while(it != img.end()) {
	  ++hist0.at((*it).getRed());
	  ++hist1.at((*it).getGreen());
	  ++hist2.at((*it).getBlue());
	it++;
      }
      const int counterHalf = img.columns()*img.rows()/2;
      int i,s;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist0.at(i);
      }
      dest.at(0) = i-1;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist1.at(i);
      }
      dest.at(1) = i-1;
      i=-1,s=0;
      while(++i<256 && s<counterHalf) {
	s += hist2.at(i);
      }
      dest.at(2) = i-1;
    }

    // normalize to 0..1
    dest.divide(255);

    return true;
  };
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:80,代码来源:ltiBrightRGB.cpp

示例9: apply

  // On copy apply for type image!
  bool histogramRGBL::apply(const image& src,dvector& dest) const {

    if (src.empty()) {
      dest.clear();
      setStatusString("input channel empty");
      return false;
    }

    const parameters& param = getParameters();

    int theMin(0),theMax(255);

    const int lastIdx = param.cells-1;

    const float m = float(lastIdx)/(theMax-theMin);
    int y,r,g,b,l;
    int idx;
    int entries;

    vector<rgbPixel>::const_iterator it,eit;

    dest.resize(4*param.cells,0.0,false,true); // initialize with 0
    dvector theR(param.cells,0.0);
    dvector theG(param.cells,0.0);
    dvector theB(param.cells,0.0);
    dvector theL(param.cells,0.0);

    entries = 0;

    // if b too small, it's possible to calculate everything faster...

    // check if the ignore value
    if (param.considerAllData) {
      for (y=0;y<src.rows();++y) {
        const vector<rgbPixel>& vct = src.getRow(y);
        for (it=vct.begin(),eit=vct.end();it!=eit;++it) {
          r = (*it).getRed();
          g = (*it).getGreen();
          b = (*it).getBlue();
          l = (min(r,g,b)+max(r,g,b))/2;

          idx = static_cast<int>(r*m);
          theR.at(idx)++;
          idx = static_cast<int>(g*m);
          theG.at(idx)++;
          idx = static_cast<int>(b*m);
          theB.at(idx)++;
          idx = static_cast<int>(l*m);
          theL.at(idx)++;

          entries++;
        }
      }
    } else {
      for (y=0;y<src.rows();++y) {
        const vector<rgbPixel>& vct = src.getRow(y);
        for (it=vct.begin(),eit=vct.end();it!=eit;++it) {
          if ((*it) != param.ignoreValue) {
            r = (*it).getRed();
            g = (*it).getGreen();
            b = (*it).getBlue();
            l = (min(r,g,b)+max(r,g,b))/2;

            idx = static_cast<int>(r*m);
            theR.at(idx)++;
            idx = static_cast<int>(g*m);
            theG.at(idx)++;
            idx = static_cast<int>(b*m);
            theB.at(idx)++;
            idx = static_cast<int>(l*m);
            theL.at(idx)++;

            entries++;
          }
        }
      }
    }

    if (param.smooth) {
      convolution convolver;
      convolution::parameters cpar;
      cpar.boundaryType = lti::Mirror;
      cpar.setKernel(param.kernel);
      convolver.setParameters(cpar);

      matrix<double> tmp;
      tmp.useExternData(4,param.cells,&dest.at(0));

      convolver.apply(theR,tmp.getRow(0));
      convolver.apply(theG,tmp.getRow(1));
      convolver.apply(theB,tmp.getRow(2));
      convolver.apply(theL,tmp.getRow(3));

    } else {
      dest.fill(theR,0);
      dest.fill(theG,param.cells);
      dest.fill(theB,2*param.cells);
      dest.fill(theL,3*param.cells);
    }
//.........这里部分代码省略.........
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:101,代码来源:ltiHistogramRGBL.cpp


注:本文中的image::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。