天天看點

opencv2.4.9 Canny源碼耗時對比

void Canny(InputArray _dx, InputArray _dy, InputArray _mangtitude, InputArray _mask, OutputArray _dst,

    double low_thresh, double high_thresh,

    int aperture_size, bool L2gradient);

原始:

    // the final pass, form the final image

    const uchar* pmap = map + mapstep + 1;

    uchar* pdst = dst.ptr();

    for (int i = 0; i < dx.rows; i++, pmap += mapstep, pdst += dst.step)

    {

        for (int j = 0; j < dx.cols; j++)

            pdst[j] = (uchar)-(pmap[j] >> 1);

    }

耗時:0.0317318s

修改為:

dst = mapBuf(Rect(1,1, mapBuf.cols-2, mapBuf.rows-2))>1;

耗時:0.0174107s

繼續閱讀