Subversion Repositories seema-scanner

Rev

Rev 1 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 205
1
 
1
 
2
#include <opencv2/opencv.hpp>
2
#include <opencv2/opencv.hpp>
3
 
3
 
4
cv::Mat DLP3000InterpImage(cv::Mat I){
4
cv::Mat DLP3000InterpImage(cv::Mat I){
5
    //DLP3000INTERPIMAGE Interpolates a 684 x 608 image for projection on the DLP3000
5
    //DLP3000INTERPIMAGE Interpolates a 684 x 608 image for projection on the DLP3000
6
    //diamond pixel array from a FWVGA image at 853 x 480.
6
    //diamond pixel array from a FWVGA image at 853 x 480.
7
    //
7
    //
8
    //  Input parameter:
8
    //  Input parameter:
9
    //      C (853 x 480 pixels): input image of type double
9
    //      C (853 x 480 pixels): input image of type double
10
    //
10
    //
11
    //  Output parameter:
11
    //  Output parameter:
12
    //      I (684 x 608 matrix): output image
12
    //      I (684 x 608 matrix): output image
13
    //
13
    //
14
    //  Note that using a 853 x 480 provides the correct aspect ratio for projecting on the DLP3000.
14
    //  Note that using a 853 x 480 provides the correct aspect ratio for projecting on the DLP3000.
15
    //  Note that the code assumes that the image is projected 1:1 aka "short-axis flip".
15
    //  Note that the code assumes that the image is projected 1:1 aka "short-axis flip".
16
    //
16
    //
17
    //  DTU 2013, Jakob Wilm
17
    //  DTU 2013, Jakob Wilm
18
 
18
 
19
    cv::Mat ret(684, 608, CV_8U);
19
    cv::Mat ret(684, 608, CV_8U);
20
 
20
 
21
    if(I.rows != 480 || I.cols != 853){
21
    if(I.rows != 480 || I.cols != 853){
22
        std::cerr << "Input image has wrong dimensions" << std::endl;
22
        std::cerr << "Input image has wrong dimensions" << std::endl;
23
        return ret;
23
        return ret;
24
    }
24
    }
25
 
25
 
26
    // interpolation points
26
    // interpolation points
27
    float mdiag = 853.0/607.5; // mirror diagonal in input pixels
27
    float mdiag = 853.0/607.5; // mirror diagonal in input pixels
28
 
28
 
29
    cv::Mat mapX(684, 608, CV_32F), mapY(684, 608, CV_32F);
29
    cv::Mat mapX(684, 608, CV_32F), mapY(684, 608, CV_32F);
30
 
30
 
31
    for(unsigned int row=0; row<684; row++){
31
    for(unsigned int row=0; row<684; row++){
32
        for(unsigned int col=0; col<608; col++){
32
        for(unsigned int col=0; col<608; col++){
33
            mapY.at<float>(row,col) = row * 479.0/683.0;
33
            mapY.at<float>(row,col) = row * 479.0/683.0;
34
            mapX.at<float>(row,col) = col*(852.0-0.5*mdiag)/607.0 + (row%2)*0.5*mdiag;
34
            mapX.at<float>(row,col) = col*(852.0-0.5*mdiag)/607.0 + (row%2)*0.5*mdiag;
35
        }
35
        }
36
    }
36
    }
37
 
37
 
38
    cv::remap(I, ret, mapX, mapY, cv::INTER_LINEAR);
38
    cv::remap(I, ret, mapX, mapY, cv::INTER_LINEAR);
39
 
39
 
40
    return ret;
40
    return ret;
41
}
41
}
42
 
42