我考虑如果我以BGRA格式传递给IplImage *input
图像,或RGBA格式,以便使用可用的插值算法调整其大小,是否会有任何问题:
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);
总结一下我的问题是:是否重要图像在BGRA数据格式在IplImage *
,而我想调整它使用cvResize()
及以上插值?
不,绝对没有区别。为了证明,你可以在这里查看:opencv代码。这段代码有点难读,因为它使用了数学插值公式和sse intrinsic的符号。
相同的权重用于插值R,G,B, a。