简体   繁体   English

如何使用自定义颜色的OpenCV旋转图像,以消除边缘周围的间隙?

[英]How can an image be rotated with OpenCV with a custom colour for the gaps around the edge?

I would like to rotate an image in OpenCV (I'm currently doing it this way image manipulation SO answer ) but would like to specify the colour used to fill the gaps created by the rotation - by default, it's black (see below) 我想在OpenCV中旋转图像(我目前正在以这种方式进行图像处理,例如SO Answer ),但想指定用于填充旋转所产生的间隙的颜色-默认情况下为黑色(请参见下文)

在此处输入图片说明

How could this be done? 怎么办呢?

I think the answer lies in the official doc : 我认为答案在于官方文档

C: void cvWarpAffine(const CvArr* src, CvArr* dst, const CvMat* map_matrix, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar fillval=cvScalarAll(0) )

where 哪里

CvScalar fillval=cvScalarAll(0) specifies the fill color of the "gap". CvScalar fillval=cvScalarAll(0)指定“间隙”的填充颜色。

Just specify the fillval with a color scalar when calling this function. 只需在调用此函数时用颜色标量指定fillval

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM