PNG rotation without dark edge
When a PNG is rotated or blurred there is a dark edge appearing (see image A).
It appears partially or totally on large shapes, but it's always visible on thin shapes.shapes.
Do you know how to rotate or blur a PNG image with OpenCV without the dark edge?
I tried all the interpolations shown here. Only INTER_NEAREST doesn't produce dark edge, but the quality is not usable.
Rotation code sample:
cv::Size ImageSize = cv::Size(500, 500);
cv::Mat Image(ImageSize, MatType, ImageDataPtr);
cv::Point2f ImageCenter(round(Image.cols/2), round(Image.rows/2));
cv::Mat TransMat = cv::getRotationMatrix2D(ImageCenter, Angle, 1.0);
cv::Rect BoundingBox = cv::RotatedRect(ImageCenter, ImageSize, Angle).boundingRect();
TransMat.at<double>(0, 2) += BoundingBox.width / 2.0 - ImageCenter.x;
TransMat.at<double>(1, 2) += BoundingBox.height / 2.0 - ImageCenter.y;
cv::Mat RotatedImage;
cv::warpAffine(Image, RotatedImage, TransMat, BoundingBox.size(), cv::INTER_CUBIC);
Blur code sample:
cv::Mat BlurredImage;
cv::blur(Image, BlurredImage, cv::Size(2, 2), cv::Point(-1,-1), cv::BORDER_TRANSPARENT);
// OR
cv::Mat BlurredImage;
cv::blur(Image, BlurredImage, cv::Size(2, 2));