I’m using the following code to rotate images in opencv. However, afterwards the corners are colored in black. I thought when I set borderMode to BORDER_CONSTANT I can specify the color. But whatever color I set (the last parameter), the result is always black.
cv::Mat rotated;
float rotation = 3.0f;
cv::warpAffine(img,
rotated,
rotation,
img.size(),
cv::INTER_CUBIC,
cv::BORDER_CONSTANT,
cv::Scalar(1.0, 1.0, 1.0, 0.0));
cv::imshow("rotated", rotated);
Could someone please explain me, what I am doing wrong here?
I know I could use cv::floodFill afterwards, but somehow it should be possible to do using only warpAffine.
Did you try some values bigger than 1? White should be
Blue:
And so on.
Values in OpenCV matrices are expressed as uchars (0..255), and not (0.0..1.0)