# Revision history [back]

The closest I think you can do is the inpainting algorithms. They are in two places, photo and xphoto.

You would need to set the mask with non-zero pixels where it needs to be in-painted. I would suggest a width of twice what you need padded so when the white is inpainted too.

Alternatively, try doing the dilate again, but copy the original ROI into the dialated image. The copyTo function allows a mask parameter, so that's easy. The only changes would be where the dilation expanded outward.

The closest I think you can do is the inpainting algorithms. They are in two places, photo and xphoto.

You would need to set the mask with non-zero pixels where it needs to be in-painted. I would suggest a width of twice what you need padded so when the white is inpainted too.

Alternatively, try doing the dilate again, but copy the original ROI into the dialated image. The copyTo function allows a mask parameter, so that's easy. The only changes would be where the dilation expanded outward.

Edit: So, out of curiosity, if this isn't what you wanted, then what is? Can you describe what's wrong? This is the dilate with copy on a 30x30 kernel.

The closest I think you can do is the inpainting algorithms. They are in two places, photo and xphoto.

You would need to set the mask with non-zero pixels where it needs to be in-painted. I would suggest a width of twice what you need padded so when the white is inpainted too.

Alternatively, try doing the dilate again, but copy the original ROI into the dialated image. The copyTo function allows a mask parameter, so that's easy. The only changes would be where the dilation expanded outward.

Edit: So, out of curiosity, if this isn't what you wanted, then what is? Can you describe what's wrong? This is the dilate with copy on a 30x30 kernel. kernel.

Edit2: I had an idea. How to actually accomplish this. Here's the picture:

And here's the code:

Mat flower = imread("flower.png",-1);
Mat border, borderTemp;

linearPolar(flower, largeFlower, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200, INTER_CUBIC);
for (int r = 0; r < largeFlower.rows; ++r)
{
Rect petal;
petal.y = r;
petal.height = 1;
for (int c = 0; c < largeFlower.cols; ++c)
{
if (largeFlower.at<Vec<uchar, 4> >(r, c)(3) == 0)
{
if (petal.x < 0)
{
int diff = 0 - petal.x;
petal.x = 0;
petal.width -= diff;
}
break;
}
}
largeFlower(petal).copyTo(borderTemp);
copyMakeBorder(borderTemp, border, 0, 0, 0, padding, BORDER_REFLECT);
petal.width = border.cols;
std::wcout << border.cols << ", " << border.rows << "\n";
border.copyTo(largeFlower(petal));
std::cout << r << "/" << largeFlower.rows << "\n";
}
linearPolar(largeFlower, border, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200.0, INTER_CUBIC + WARP_INVERSE_MAP);

imshow("flower", flower);
imshow("border", border);
imshow("Polar", largeFlower);
imwrite("border_mirror.png", border);
waitKey();


The closest I think you can do is the inpainting algorithms. They are in two places, photo and xphoto.

You would need to set the mask with non-zero pixels where it needs to be in-painted. I would suggest a width of twice what you need padded so when the white is inpainted too.

Alternatively, try doing the dilate again, but copy the original ROI into the dialated image. The copyTo function allows a mask parameter, so that's easy. The only changes would be where the dilation expanded outward.

Edit: So, out of curiosity, if this isn't what you wanted, then what is? Can you describe what's wrong? This is the dilate with copy on a 30x30 kernel.

Edit2: I had an idea. How to actually accomplish this. Here's the picture:

And here's the code:

Mat flower = imread("flower.png",-1);
Mat border, borderTemp;

linearPolar(flower, largeFlower, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200, INTER_CUBIC);
for (int r = 0; r < largeFlower.rows; ++r)
{
Rect petal;
petal.y = r;
petal.height = 1;
for (int c = 0; c < largeFlower.cols; ++c)
{
if (largeFlower.at<Vec<uchar, 4> >(r, c)(3) == 0)
{
if (petal.x < 0)
{
int diff = 0 - petal.x;
petal.x = 0;
petal.width -= diff;
}
break;
}
}
largeFlower(petal).copyTo(borderTemp);
copyMakeBorder(borderTemp, border, 0, 0, 0, padding, BORDER_REFLECT);
petal.width = border.cols;
std::wcout << border.cols << ", " << border.rows << "\n";
border.copyTo(largeFlower(petal));
std::cout << r << "/" << largeFlower.rows << "\n";
}
linearPolar(largeFlower, border, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200.0, INTER_CUBIC + WARP_INVERSE_MAP);

imshow("flower", flower);
imshow("border", border);
imshow("Polar", largeFlower);
imwrite("border_mirror.png", border);
waitKey();


The closest I think you can do is the inpainting algorithms. They are in two places, photo and xphoto.

You would need to set the mask with non-zero pixels where it needs to be in-painted. I would suggest a width of twice what you need padded so when the white is inpainted too.

Alternatively, try doing the dilate again, but copy the original ROI into the dialated image. The copyTo function allows a mask parameter, so that's easy. The only changes would be where the dilation expanded outward.

Edit: So, out of curiosity, if this isn't what you wanted, then what is? Can you describe what's wrong? This is the dilate with copy on a 30x30 kernel.

Edit2: I had an idea. How to actually accomplish this. Here's the picture:

And here's the code:

Mat flower = imread("flower.png",-1);
Mat border, borderTemp;

linearPolar(flower, largeFlower, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200, INTER_CUBIC);

//Handle the fuzzy alpha boundary.

for (int r = 0; r < largeFlower.rows; ++r)
{
Rect petal;
petal.y = r;
petal.height = 1;
for (int c = 0; c < largeFlower.cols; ++c)
{
if (largeFlower.at<Vec<uchar, 4> >(r, c)(3) == 0)
{
if (petal.x < 0)
{
int diff = 0 - petal.x;
petal.x = 0;
petal.width -= diff;
}
break;
}
}
largeFlower(petal).copyTo(borderTemp);
copyMakeBorder(borderTemp, border, 0, 0, 0, padding, BORDER_REFLECT);
petal.width = border.cols;
border.copyTo(largeFlower(petal));
}
linearPolar(largeFlower, border, Point2f(flower.cols / 2.0, flower.rows / 2.0), 200.0, INTER_CUBIC + WARP_INVERSE_MAP);

imshow("flower", flower);
imshow("border", border);
imshow("Polar", largeFlower);
imwrite("border_mirror.png", border);
waitKey();