本文整理汇总了C++中DImage::numChannels方法的典型用法代码示例。如果您正苦于以下问题:C++ DImage::numChannels方法的具体用法?C++ DImage::numChannels怎么用?C++ DImage::numChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImage
的用法示例。
在下文中一共展示了DImage::numChannels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getImageVerticalProfile
/**Each row of img is projected onto the vertical axis. Resulting
data length will be equal to the height of img. The profile is a summation
of the grayscale values in each row. If fNormalize is true, then each value
is divided by img.width() so it is the average grayscale value for the row
instead of the sum.
If fNormalize is true, the resulting profile values are divided by the image
width.
*/
void DProfile::getImageVerticalProfile(const DImage &img, bool fNormalize){
int w, h;
w = img.width();
h = img.height();
// allocate the rgProf array
if(NULL == rgProf){
rgProf = (double*)malloc(h * sizeof(double));
D_CHECKPTR(rgProf);
len = h;
}
else{
if(len != h){
rgProf = (double*)realloc(rgProf,h*sizeof(double));
D_CHECKPTR(rgProf);
len = h;
}
}
switch(img.getImageType()){
case DImage::DImage_u8:
{
D_uint8 *pu8;
pu8=img.dataPointer_u8();
for(int y = 0, idx=0; y < h; ++y){
rgProf[y] = 0.;
for(int x = 0; x < w; ++x, ++idx){
rgProf[y] += pu8[idx];
}
if(fNormalize)
rgProf[y] /= w;
}
}
break;
case DImage::DImage_flt_multi:
{
float *pflt;
if(img.numChannels() > 1){
fprintf(stderr,"DProfile::getImageVerticalProfile() floats only "
"supported with a single channel\n");
abort();
}
pflt=img.dataPointer_flt(0);
for(int y = 0, idx=0; y < h; ++y){
rgProf[y] = 0.;
for(int x = 0; x < w; ++x, ++idx){
rgProf[y] += pflt[idx];
}
if(fNormalize)
rgProf[y] /= w;
}
}
break;
default:
fprintf(stderr, "Not yet implemented!\n");
abort();
}//end switch(img.getImageType())
}