Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You're building your maps wrong. This is in C++, but it's not too far off what you need in Python.

In this case I used the function 10*log(x+1)+x/2. You replace that with your function, or in your case, curve_y_points[j].

Mat img = imread("image.jpg");
Mat mapX, mapY;
mapX.create(img.rows, img.cols, CV_32F);
for (int x = 0; x < img.cols; ++x)
{
    mapX.col(x).setTo(x);
}
mapY.create(img.rows, img.cols, CV_32F);
for (int y = 0; y < img.rows; ++y)
{
    for (int x = 0; x < img.cols; ++x)
    {
        mapY.at<float>(y, x) = (float)y*img.rows / (img.rows - (10*log((float)x + 1.0f)+x/2.0f));
        if (x == 100)
            std::cout << y << "  " << mapY.at<float>(y, x) << "\n";
    }
}
Mat remImg;
remap(img, remImg, mapX, mapY, INTER_LINEAR, BORDER_CONSTANT);
imshow("img", img);
imshow("remapped", remImg);
waitKey();

image description