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


C++ CImg::RGBtoYCbCr方法代码示例

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


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

示例1: ph_dct_imagehash

int ph_dct_imagehash(const char* file,ulong64 &hash){

    if (!file){
        return -1;
    }
    CImg<uint8_t> src;
    try {
        src.load(file);
    } catch (CImgIOException ex){
        return -1;
    }
    CImg<float> meanfilter(7,7,1,1,1);
    CImg<float> img;
    if (src.spectrum() == 3){
        img = src.RGBtoYCbCr().channel(0).get_convolve(meanfilter);
    } else if (src.spectrum() == 4){
        int width = img.width();
        int height = img.height();
        int depth = img.depth();
        img = src.crop(0,0,0,0,width-1,height-1,depth-1,2).RGBtoYCbCr().channel(0).get_convolve(meanfilter);
    } else {
        img = src.channel(0).get_convolve(meanfilter);
    }

    img.resize(32,32);
    CImg<float> *C  = ph_dct_matrix(32);
    CImg<float> Ctransp = C->get_transpose();

    CImg<float> dctImage = (*C)*img*Ctransp;

    CImg<float> subsec = dctImage.crop(1,1,8,8).unroll('x');;

    float median = subsec.median();
    ulong64 one = 0x0000000000000001;
    hash = 0x0000000000000000;
    for (int i=0;i< 64;i++){
        float current = subsec(i);
        if (current > median)
            hash |= one;
        one = one << 1;
    }

    delete C;

    return 0;
}
开发者ID:visionor,项目名称:logo_detection,代码行数:46,代码来源:pHash.cpp

示例2: ph_bmb_imagehash

int ph_bmb_imagehash(const char *file, uint8_t method, BinHash **ret_hash)
{
    CImg<uint8_t> img;
    const uint8_t *ptrsrc;  // source pointer (img)
    uint8_t *block;
    int pcol;  // "pointer" to pixel col (x)
    int prow;  // "pointer" to pixel row (y)
    int blockidx = 0;  //current idx of block begin processed.
    double median;  // median value of mean_vals
    const int preset_size_x=256;
    const int preset_size_y=256;
    const int blk_size_x=16;
    const int blk_size_y=16;
    int pixcolstep = blk_size_x;
    int pixrowstep = blk_size_y;

    int number_of_blocks;
    uint32_t bitsize;
    // number of bytes needed to store bitsize bits.
    uint32_t bytesize;

    if (!file || !ret_hash){
        return -1;
    }
    try {
        img.load(file);
    } catch (CImgIOException ex){
        return -1;
    }

    const int blk_size = blk_size_x * blk_size_y;
    block = (uint8_t*)malloc(sizeof(uint8_t) * blk_size);

    if(!block)
        return -1;

    switch (img.spectrum()) {
    case 3: // from RGB
        img.RGBtoYCbCr().channel(0);
        break;
    default:
        *ret_hash = NULL;
        free(block);
        return -1;
    }

    img.resize(preset_size_x, preset_size_y);

    // ~step b
    ptrsrc = img.data();  // set pointer to beginning of pixel buffer

    if(method == 2)
    {
        pixcolstep /= 2;
        pixrowstep /= 2;

        number_of_blocks =
            ((preset_size_x / blk_size_x) * 2 - 1) *
            ((preset_size_y / blk_size_y) * 2 - 1);
    } else {
        number_of_blocks =
            preset_size_x / blk_size_x *
            preset_size_y / blk_size_y;
    }

    bitsize= number_of_blocks;
    bytesize = bitsize / 8;

    double *mean_vals = new double[number_of_blocks];

    /*
    * pixel row < block < block row < image
    *
    * The pixel rows of a block are copied consecutively
    * into the block buffer (using memcpy). When a block is
    * finished, the next block in the block row is processed.
    * After finishing a block row, the processing of the next
    * block row is started. An image consists of an arbitrary
    * number of block rows.
    */

    /* image (multiple rows of blocks) */
    for(prow = 0;prow<=preset_size_y-blk_size_y;prow += pixrowstep)
    {

        /* block row */
        for(pcol = 0;pcol<=preset_size_x-blk_size_x;pcol += pixcolstep)
        {

            // idx for array holding one block.
            int blockpos = 0;

            /* block */

            // i is used to address the different
            // pixel rows of a block
            for(int i=0 ; i < blk_size_y; i++)
            {
                ptrsrc = img.data(pcol, prow + i);
                memcpy(block + blockpos, ptrsrc, blk_size_x);
//.........这里部分代码省略.........
开发者ID:visionor,项目名称:logo_detection,代码行数:101,代码来源:pHash.cpp

示例3: RGBtoYCbCr

//' @export
// [[Rcpp::export]]
NumericVector RGBtoYCbCr(NumericVector im) {
    CImg<double> img = as<CImg<double> >(im);
    img.RGBtoYCbCr();
    return wrap(img);
}
开发者ID:antoinececchi,项目名称:imager,代码行数:7,代码来源:colourspace.cpp


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