본문 바로가기
카테고리 없음

왜곡 보정의 잘못된 이해

by 어다프 2020. 2. 18.


void Undistortion::makeLookUpTable() {
    int width, height, x, y, px, py, level, i, i2, i3, i4;

    // Set lut table without interpolation
    for (level=MIN_LEVEL; level<MAX_LEVEL; level++) {
        width = s_info.width[level];
        height = s_info.height[level];
        for(y=0; y<height; y++) {
            for(x=0; x<width; x++) {
                px = x;
                py = y;
                distortPixel(px, py);
                i = y*width+x; i2 = y*width+(x+1); i3 = (y+1)*width+x; i4 = (y+1)*width+(x+1);
                if(px>=0 && py>=0 && px                    s_info.lut[level][i].pos = py*width+px;
                    s_info.lut[level][i].p[0] = s_info.lut[level][i].pos; // left top
                    s_info.lut[level][i].p[1] = s_info.lut[level][i2].pos; // right top
                    s_info.lut[level][i].p[2] = s_info.lut[level][i3].pos; // left bottom
                    s_info.lut[level][i].p[3] = s_info.lut[level][i4].pos; // right bottom
                }
                else {
                    s_info.lut[level][i].pos = 0; // -> 나는 여기서 0이 들어가길래 ......... 이게 물결모양 만드는 원인이라고 생각함..
                }
            }
        }
    }
}

 

물결모양을 만드는 이유는

 

        어떤 x, y에 대해 distortPixel(px, py)를 통해 px, py를 구하면 그 값이 같은 경우가 존재.

        예를 들어 x, y가 3, 2 일때 px, py가 4, 5인 경우와 x, y가 4, 3 일 때 px, py가 4, 5인 경우가 존재.

        그렇다면 결론적으로 주위 픽셀이 같은 값을 가지게 되는 경우가 생기므로 계단 현상 (물결 현상)이 발생하는 것으로 보임.