OpenCV图像大小调整和输入位图格式

时间:2016-10-07 14:13:25

标签: c opencv bitmap

如果我以BGRA格式或RGBA格式传递IplImage *input图像以便使用可用的插值算法进行大小调整,我会考虑是否会有任何问题:

NTER_NEAREST - a nearest-neighbor interpolation
INTER_LINEAR - a bilinear interpolation (used by default)
INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

将调整大小的图像返回到RGBA缓冲区。所以我认为转换RGBA -> BGRA和调整后BGRA -> RGBA之后的额外操作将是多余的,只会减慢我的图像大小调整速度。也许我错了,重要的是当使用上面的插值时,图像将采用正确格式的BGRA。

IplImage *image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 4);
    cvSetData(image, rgbaData, image->widthStep);

    // resize image
    float scale = 0.5;
    IplImage *resizedImage = cvCreateImage(cvSize(image->width*scale, image->height*scale), image->depth, image->nChannels);
    cvResize(image, resizedImage, CV_INTER_LANCZOS4);

总结一下我的问题是: 图片IplImage *中的 BGRA 数据格式是否重要,而我想调整大小使用{{1及以上插值?

1 个答案:

答案 0 :(得分:2)

不,绝对没有区别。有关证明,您可以在此处查看:opencv code。代码有点难以阅读,因为它使用了数学插值公式和sse内在函数的符号。

相同的权重用于插值R,G,B,A。