Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can use remap for your shearing transformation:

const float a = 0.27; // it's a constant ?
Mat img = imread("../img/grid.jpg");
Mat_<Vec2f> prjMap(img.size());
for (int x=0; x<img.cols; x++) {
    for (int y=0; y<img.rows; y++) {
        float u = x - y * tan(a);
        float v = y;
        prjMap(y, x) = Vec2f(u,v);
    }
}
Mat projected;
remap(img, projected, prjMap, cv::Mat(), INTER_LINEAR);

you can use remap for your shearing transformation:

const float a = 0.27; // it's a constant ?
Mat img = imread("../img/grid.jpg");
Mat_<Vec2f> prjMap(img.size());
for (int x=0; x<img.cols; x++) {
    for (int y=0; y<img.rows; y++) {
        float u = x - y * tan(a);
        float v = y;
        prjMap(y, x) = Vec2f(u,v);
    }
}
Mat projected;
remap(img, projected, prjMap, cv::Mat(), INTER_LINEAR);

input

output