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


C++ DImage::convertedImgType方法代码示例

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


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

示例1: getTextlineRects


//.........这里部分代码省略.........
      sumWeights += numPxls;
    }
    printf("    sumPxls=%f sumWeights=%f\n",sumPxls, sumWeights);
    if(sumWeights > 0)
      sumPxls /= sumWeights;
    else
      sumPxls = 0;

    printf("    weighted avg number of pixels per line:%f\n",sumPxls);
    pxlThresh = sumPxls/10;
    printf("    pixel threshold=%ld\n",pxlThresh);
    
    //now get rid of lines with few pixels
    for(int p=(*numTextlines)-1; p >=0; --p){
      if(rgNumPixels[p] < pxlThresh){// one-twentieth of weighted avg
	printf("    remove textline %d (y=%d to y=%d) with %ld pixels\n",p,
	       (*rgTextlineRects)[p].y,(*rgTextlineRects)[p].y+
	       (*rgTextlineRects)[p].h, rgNumPixels[p]);
	for(int r=p; r < ((*numTextlines)-1); ++r){
	  (*rgTextlineRects)[r] = (*rgTextlineRects)[r+1];
	}
	--(*numTextlines);
      }
    }

    free(rgNumPixels);
  }

  printf("   There are now %d textlines\n", (*numTextlines));

  //debug: save an image with the textline rectangles drawn
  {
    DImage imgTextlines;
    imgTextlines = img.convertedImgType(DImage::DImage_RGB);
    for(int p = 0; p < (*numTextlines); ++p){
      int colorR, colorG, colorB;
      printf("\trect%d: x,y wxh=%d,%d %dx%d\n",p,(*rgTextlineRects)[p].x,
	     (*rgTextlineRects)[p].y,
	     (*rgTextlineRects)[p].w,(*rgTextlineRects)[p].h);
      colorR = ((p+1)*127) % 255;
      colorG = (p*127) % 255;
      colorB = (p) % 255;
      imgTextlines.drawRect((*rgTextlineRects)[p].x,(*rgTextlineRects)[p].y,
			    (*rgTextlineRects)[p].x+(*rgTextlineRects)[p].w-1,
			    (*rgTextlineRects)[p].y+(*rgTextlineRects)[p].h,
			    colorR, colorG, colorB);
      imgTextlines.drawRect((*rgTextlineRects)[p].x+1,(*rgTextlineRects)[p].y+1,
			    (*rgTextlineRects)[p].x+(*rgTextlineRects)[p].w-1-1,
			    (*rgTextlineRects)[p].y+(*rgTextlineRects)[p].h-1,
			    colorR, colorG, colorB);
      imgTextlines.drawRect((*rgTextlineRects)[p].x+2,(*rgTextlineRects)[p].y+2,
			    (*rgTextlineRects)[p].x+(*rgTextlineRects)[p].w-1-2,
			    (*rgTextlineRects)[p].y+(*rgTextlineRects)[p].h-2,
			    colorR, colorG, colorB);
    }
    sprintf(stTmp,"%s_tl_rects.pgm",stDebugBaseName);
    imgTextlines.save(stTmp);

  }





//   // now get x-height estimate using profiles (or black runlengths of smears)
// #if 0
开发者ID:herobd,项目名称:intel_index,代码行数:67,代码来源:dtextlineseparator.cpp

示例2: if


//.........这里部分代码省略.........
	    fLead = -1;
	  }
	}
	else{
	  if(pdbl[y] > peaksThresh)
	    fLead = y;
	}
      }
      if(numPeaks >= bestNumPeaks){
	bestNumPeaks = numPeaks;
	bestNumPeaksThresh = peaksThresh;
      }
    }
    rgSmearThresh[i] = bestNumPeaksThresh;
#endif


  }

  // now get x-height estimate using profiles (or black runlengths of smears)


  //debug: save an image with all of the profiles
  {
    DImage imgProfsAll;
    DImage imgProfsRLAll;
    imgProfsAll.create(w,h,DImage::DImage_u8);
    stripW = (w + numStrips-1) / numStrips;
    for(int i=0; i < numStrips*2-1; ++i){
      DImage imgTmp;
      imgTmp = rgProfs[i].toDImage(stripW/2,true);
      imgProfsAll.pasteFromImage(i*stripW/2,0,imgTmp,0,0,stripW/2,h);
    }
    imgProfsAll = imgProfsAll.convertedImgType(DImage::DImage_RGB);
    for(int i=0; i < numStrips*2-1; ++i){
      int peakLineOffs;
      // peakLineOffs = stripW/2 * rgPeakThresh[i] / rgProfs[i].max();
      peakLineOffs = (int)(rgPeakLineOffs[i]*stripW/2);
      // printf(" rgPeakLineOffs[%d]=%lf peakLineOffs=%d\n",i,rgPeakLineOffs[i],
      // 	     peakLineOffs);
      imgProfsAll.drawLine(i*stripW/2 + peakLineOffs+1, 0,
			   i*stripW/2 + peakLineOffs+1, h-1, 255-i,0,0);
      imgProfsAll.drawLine(i*stripW/2 + peakLineOffs, 0,
			   i*stripW/2 + peakLineOffs, h-1, 255-i,0,0);
      imgProfsAll.drawLine(i*stripW/2, 0,
			   i*stripW/2, h-1, 0, 255-i,0);
    }

    sprintf(stTmp,"%s_allprofs.pgm",stDebugBaseName);
    imgProfsAll.save(stTmp);
  }

  //debug: save an image with all of the smeared profiles
  {
    DImage imgProfsAll;
    DImage imgProfsRLAll;
    imgProfsAll.create(w,h,DImage::DImage_u8);
    stripW = (w + numStrips-1) / numStrips;
    for(int i=0; i < numStrips*2-1; ++i){
      DImage imgTmp;
      imgTmp = rgProfsSmear[i].toDImage(stripW/2,true);
      imgProfsAll.pasteFromImage(i*stripW/2,0,imgTmp,0,0,stripW/2,h);
    }
    imgProfsAll = imgProfsAll.convertedImgType(DImage::DImage_RGB);
    for(int i=0; i < numStrips*2-1; ++i){
开发者ID:herobd,项目名称:intel_index,代码行数:66,代码来源:dtextlineseparator.cpp


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