Depth Image Reconstruction MAP Based 3D
1 개요
초점이 다른 이미지들의 초점 측정치를 기반으로 대상의 높이를 추정하는 알고리즘
2 알고리즘 상세 설명
Source Images | Destination Texture Image | Destination Height Map Image |
---|---|---|
![]() |
![]() |
![]() |
최대 초점 측정치가 높은 페이지 인덱스를 높이의 기준점으로 삼습니다. 여기에 다른 페이지들의 초점 측정치 분포를 참고하여 신뢰도를 계산하고 기준점을 중심으로한 정규분포를 가정하여 최대 사후 확률 추정(MAP)으로 높이를 추정하여 출력합니다.
인근 픽셀과 색상이 유사한 픽셀의 경우 서로 유사한 높이임을 가정합니다.
Destination 3D Object |
---|
![]() |
행렬 연산을 위해 CGM(Conjugate Gradient Method) 를 사용하는 반복적인 방식이므로, 경우에 따라 누적된 부동 소숫점 오차에 의한 발산 가능성이 존재합니다. 따라서 적정 수준의 반복 횟수를 설정하는 것이 권장됩니다.
높은 색상 대비 지점의 defocus 는 주변 픽셀의 잘못된 초점 측정을 유발하므로, defocus 에 의한 영향력을 무시 할 수 있는 정도의 texture 또는 낮은 색상 대비가 요구됩니다.
texture 가 존재하지 않는 평평한 단일 높이 영역에 대하여 사용자의 사전 지식을 활용하기 위해 해당 페이지에 대하여 초점 측정 bias 를 적용할 수 있습니다.
이 경우, 텍스쳐가 부족하더라도 해당 bias 값이 텍스쳐를 생성하므로 모든 페이지에 대해 낮은 초점 측정치를 지닌 영역에 대해 힌트가 될 수 있습니다.
Local Regularization 0.02 | Local Regularization 0.2 | Local Regularization 2.0 |
---|---|---|
![]() |
![]() |
![]() |
다양한 파라미터들을 통하여 출력물의 품질을 조절할 수 있습니다. Local 정규화 수치, 바이어스 수치, CGM 반복 횟수, DoG 인 경우 sigma 값 설정 등을 통해 중점적으로 이루어집니다.
페이지 간 Alignment 가 맞지 않는 경우 이를 보정하기 위한 파라미터들이 있으며, 해당 옵션들은 내부에서 Perspective 알고리즘을 호출하는데 사용됩니다.
출력 Height 이미지의 높이 배율이 필요한 경우 파라미터를 통해 설정할 수 있습니다.
3 파라미터 설정 및 사용 방법
Page Alignment 보정
CResult SetFirstPageAlignment(const CFLFigure& flfFirstPageAlignment)
Perspective 알고리즘의 파라미터를 계산하기 위한 첫 번째 페이지의 alignment 도형을 설정합니다. Rect 또는 Quad 가 허용되며, 중간 페이지의 경우 두 도형 의 가중평균을 Perspective 알고리즘의 입력으로 사용합니다.
모든 페이지의 이미지에서 두 도형의 평균 도형을 타겟으로 변환됩니다.flfFirstPageAlignment
: 첫 번째 페이지의 alignment 도형
const CResult SetLastPageAlignment(const CFLFigure& flfLastPageAlignment)
Perspective 알고리즘의 파라미터를 계산하기 위한 마지막 페이지의 alignment 도형을 설정합니다. Rect 또는 Quad 가 허용되며, 중간 페이지의 경우 두 도형 의 가중평균을 Perspective 알고리즘의 입력으로 사용합니다.
모든 페이지의 이미지에서 두 도형의 평균 도형을 타겟으로 변환됩니다.flfLastPageAlignment
: 마지막 페이지의 alignment 도형
Calculation 정밀도 설정
const CResult SetAccuracy(EFloatingPointAccuracy eAccuracy )
Cuda 및 CPU 연산 시 메모리 저장에 사용할 부동 소수점 정밀도를 설정합니다. 중간 연산 방식은 오차로 인한 결과 오류 방지를 위해 공통적으로 double 타입이 사용되나, 연산 결과 데이터를 32-bit 로 저장 시 일부 정밀도가 손실될 가능성이 있습니다.eAccuracy
: 연산 정밀도
Default: EFloatingPointAccuracy_Bit32- EFloatingPointAccuracy_Bit32
- EFloatingPointAccuracy_Bit64
Focus Measure 파라미터 설정
const CResult SetFMBiasPageIndex(int64_t i64PageIndex)
Focus Measure 시 어떤 페이지에 바이어스를 가할 것인지 설정합니다.
모든 페이지에 걸쳐 텍스쳐가 없는 영역에 대하여 일괄적으로 어떤 높이를 가질 것인지 힌트를 제공하는 역할을 수행합니다.i64KernelHalfSize
: 바이어스를 가할 페이지 인덱스
Default: 0
const CResult SetFMBiasValue(double f64BiasValue)
Focus Measure 시 지정된 페이지의 초점 측정치에 바이어스를 얼마나 더할 것인지 설정합니다. 적절한 수치는 이미지의 초점 측정 값과 관계가 있으며, 과도하게 높은 값을 입력 시 바이어스의 크기가 초점 측정에 대해 지배적이 될 수 있으므로 적정한 값을 입력해야 합니다.
모든 페이지에 걸쳐 텍스쳐가 없는 영역에 대하여 일괄적으로 어떤 높이를 가질 것인지 힌트를 제공하는 역할을 수행합니다.f64BiasValue
: 바이어스 수치
Default: 0.0 [0.0, ...)
const CResult SetFocusMeasureMethod(EFocusMeasureMethod eFocusMeasureMethod)
Focus Measure 시 사용할 초점 측정 함수를 설정합니다.eFocusMeasureMethod
: 초점 측정 함수
Default: EFocusMeasureMethod_DoG- EFocusMeasureMethod_DoG : Difference of Gaussian
- EFocusMeasureMethod_Laplacian8 : Laplacian 8
const CResult SetSigma1(double f64Sigma1)
초점 측정 함수로 DoG 가 선택된 경우 사용되는 파라미터인 를 설정합니다.
f64Sigma1
: sigma 1
Default: 0.5 (0.0, 1.0]
const CResult SetSigma2(double f64Sigma2)
초점 측정 함수로 DoG 가 선택된 경우 사용되는 파라미터인 를 설정합니다.
f64Sigma2
: sigma 2
Default: 0.8 (0.0, 1.0]
Optimization 파라미터 설정
const CResult SetLocalRegularizationFactor(double f64Factor)
오버피팅을 규제하는 로컬 규제를 설정합니다. 해당 수치가 낮은 경우, 날카로운 표면이 형성됩니다. 해당 수치가 높은 경우, 부드러운 표면을 형성합니다.f64Factor
: local regularization factor
Default: 0.001 (0.0, ...)
const CResult SetGlobalRegularizationFactor(double f64Factor)
전역 행렬을 정규화 하기위해 대각 행렬에 더해지는 값입니다.f64Factor
: global regularization factor
Default: 0.0000000001 [0.0, ...)
const CResult SetCGMTolerance(double f64Tolerance)
CGM 의 반복 횟수의 종료 조건 중 하나인 잔차의 L2 Norm 크기에 대한 Tolerance 를 설정합니다.f64Tolerance
: CGM tolerance
Default: 0.01 Recommanded: 0.1, 0.01, 0.001, 0.0001
const CResult SetCGMMaxIterations(int64_t i64MaxIterations)
CGM 의 반복 횟수의 종료 조건 중 하나인 최대 반복 횟수를 설정합니다.i64MaxIterations
: CGM max iteration
Default: 100 Recommanded: 10, 20, 30, 50, 80, 100, 150
출력 이미지 높이 배율 설정
const CResult SetDirection(EDirection eDirection)
입력 이미지의 페이지 인덱스가 순차적으로 정렬된 방식을 설정합니다. 해당 옵션에 의해 출력물의 돌출 방향이 달라집니다.eDirection
: 페이지의 포커스 거리 정렬 방식
Default: EDirection_BottomToTop- EDirection_BottomToTop: 카메라와 먼 곳(Bottom) 부터 가까운 곳(Top)이 포커스된 이미지 순서로 정렬된 경우
- EDirection_TopToBottom: 카메라와 가까운 곳(Top) 부터 먼 곳(Bottom)이 포커스된 이미지 순서로 정렬된 경우
const CResult SetPixelAccuracy(double f64PixelAccuracyMM)
픽셀 당 실제 거리를 의미할 수 있으며, Result Height Map 인 Destination 이미지에 곱해질 배율을 설정하는 데 사용됩니다.f64PixelAccuracyMM
: 높이 배율의 분모
const CResult SetDepthPitch(double f64DepthPitchMM)
페이지 당 변화되는 초점 거리 변화를 의미할 수 있으며, Result Height Map 인 Destination 이미지에 곱해질 배율을 설정하는 데 사용됩니다.f64DepthPitchMM
: 높이 배율의 분자
4 예제 코드
CDepthImageReconstructionMAPBased3D depthImageReconstructionMAPBased3D;
CFLImage fliSourceImage;
CFLImage fliDestinationTextureImage;
CFLImage fliDestinationHeightMapImage;
depthImageReconstructionMAPBased3D.SetSourceImage(fliSourceImage);
depthImageReconstructionMAPBased3D.SetDestinationTextureImage(fliDestinationTextureImage);
depthImageReconstructionMAPBased3D.SetDestinationHeightMapImage(fliDestinationHeightMapImage);
depthImageReconstructionMAPBased3D.SetDestinationObject(fl3DOHM);
depthImageReconstructionMAPBased3D.Enable3DObjectGeneration(true);
depthImageReconstructionMAPBased3D.SetFMBiasPageIndex(0);
depthImageReconstructionMAPBased3D.SetFMBiasValue(0.004);
depthImageReconstructionMAPBased3D.SetFocusMeasureMethod(CDepthImageReconstructionMAPBased3D::EFocusMeasureMethod_DoG);
depthImageReconstructionMAPBased3D.SetSigma1(0.4);
depthImageReconstructionMAPBased3D.SetSigma2(0.8);
depthImageReconstructionMAPBased3D.SetLocalRegularizationFactor(0.02);
depthImageReconstructionMAPBased3D.SetCGMTolerance(0);
depthImageReconstructionMAPBased3D.SetCGMMaxIterations(50);
depthImageReconstructionMAPBased3D.SetDirection(CDepthImageReconstructionMAPBased3D::EDirection_BottomToTop);
depthImageReconstructionMAPBased3D.SetPixelAccuracy(1.0);
depthImageReconstructionMAPBased3D.SetDepthPitch(10.0);
depthImageReconstructionMAPBased3D.Execute();
5 기타 사항
Supported Feature
- Image
- Source Image
- Destination Texture Image
- Destination Height Map Image
- 3D
- Destination 3D Object
Supported Format
- Source
[in]
- Page
- 1
- Channel
- 1-10
- Combined, Separated
- Value Type & Depth
- Signed: 8, 9-16, 32
- Unsigned: 8, 9-16, 32
- Floating: 32, 64
- Page
- Destination Texture
[out]
- Channel
- Source 와 일치하는 경우 지원
- Value Type & Depth
- Texture 이미지가 있는 경우, Source 와 일치하는 경우 지원
- Texture 이미지를 생성하는 경우, Source 추종
- Channel
- Destination Height Map
[out]
- Channel
- 1
- Value Type & Depth
- Floating: 32
- Channel
- Destination 3D Object
[out]
- CFL3DObjectHeightMap