James
James

Reputation: 31738

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)

enter image description here

How could this be done?

Upvotes: 1

Views: 320

Answers (1)

SolessChong
SolessChong

Reputation: 3407

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".

Just specify the fillval with a color scalar when calling this function.

Upvotes: 2

Related Questions