콘텐츠로 이동

SaigeSurface

PhotometricStereo.SaigeSurface

Bases: PhotometricStereo

2.5D 이미지 생성을 위한 SaigeSurface class입니다.

Usage
from PhotometricStereo.engine.api import SaigeSurface

saige_surface = SaigeSurface.build()

# surface normal 계산
error_code, (normal, albedo) = saige_surface.calculate_surface_normal(img_list)

config = {
    "mode": "curvature",
    "shader_level": 4,
    "contrast": 20,
    "brightness": 5,
}

# 이미지 후처리 진행
error_code, result = saige_surface.postprocess(normal, albedo, config)

build() classmethod

SaigeSurface class의 instance를 생성합니다.

calculate_surface_normal_and_albedo(img_list, elevation=30.0)

4장의 이미지를 이용하여 surface normal과 albedo를 계산합니다. 이미지 순서가 광원 위치 기준 [left, top, right, bottom]으로 정확해야합니다. 이미지 순서가 올바르지 않을 경우, 정확한 결과를 계산할 수 없습니다.

Parameters:

Name Type Description Default
img_list List[np.ndarray]

Grayscale 이미지 리스트입니다.

img_list = [
    img_left,   # 광원이 왼쪽에 위치한 이미지 (H, W)
    img_top,    # 광원이 위에 위치한 이미지 (H, W)
    img_right,  # 광원이 오른쪽에 위치한 이미지 (H, W)
    img_bottom, # 광원이 아래에 위치한 이미지 (H, W)
]

required
elevation Optional[float]

빛의 각도입니다. Defaults to 30.0.

30.0

Raises:

Type Description
error.NotEnoughImageError

이미지가 4장이 필요합니다.

error.InvalidImageShapeError

모든 이미지는 동일한 크기여야 합니다.

error.InvalidImageShapeError

모든 이미지는 grayscale이어야 합니다.

error.ElevationAngleOutOfRangeError

Elevation angle이 0보다 작거나 90보다 큽니다.

Returns:

Type Description
Tuple[np.ndarray, np.ndarray]

Tuple[np.ndarray, np.ndarray]: surface normal, albedo


postprocess(normal, albedo, config)

surface normal map에 이미지 프로세싱 기법을 적용합니다.

  • mode : 용도에 맞게 모드를 선택합니다.
    • curvature : 흠집 검사에 적합합니다.
    • shallow : 이물 검사에 적합합니다.
    • deep : 흠집 검사에 적합합니다. 질감이 더 표현됩니다.
  • shader_level : 쉐이더 레벨입니다. 낮을 수록 평평하고 높을 수록 입체감이 드러나며, 처리시간이 소폭 증가합니다. (1~5; 기본=4)
  • contrast : 명암비입니다. 낮을 수록 대비가 낮고 높을 수록 대비가 높아집니다. (-100~100, 기본=10)
  • brightness : 이미지 밝기입니다. 낮을 수록 어두워지고 높을 수록 밝아집니다. (-30~30, 기본=0)

Parameters:

Name Type Description Default
normal np.ndarray

(3, H, W)의 크기를 가지는 surface normal map입니다.

required
albedo np.ndarray

(H, W)의 크기를 가지는 albedo map입니다.

required
config dict

이미지 프로세싱 파라미터를 담은 dictionary 입니다.

config = {
    "mode": str, # "curvature", "shallow", or "deep"
    "shader_level": int, # 1~5. default = 4
    "contrast": int, # -30~30. default = 10
    "brightness": int, # -30~30. default = 0
}

required

Returns:

Type Description
np.ndarray

np.ndarray: (H, W)의 크기를 가지는 surface normal map입니다.