λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ“– Theory/Computer Vision

μ§κ°μ’Œν‘œκ³„ & κ΅¬λ©΄μ’Œν‘œκ³„ | μ’Œν‘œ λ³€ν™˜

by 뭅즀 2024. 3. 29.
λ°˜μ‘ν˜•

직각 μ’Œν‘œκ³„μ™€ ꡬ면 μ’Œν‘œκ³„λŠ” 이미지 처리 및 λΆ„μ„μ—μ„œ μ‚¬μš©λ˜λŠ” μ’Œν‘œ μ‹œμŠ€ν…œμ΄λ‹€.

 


직각 μ’Œν‘œκ³„(Rectangular Coordinates)

  • 이미지λ₯Ό λ‹€λ£° λ•Œ κ°€μž₯ 일반적으둜 μ‚¬μš©λ˜λŠ” μ’Œν‘œ μ‹œμŠ€ν…œ
  • μ΄λ―Έμ§€λŠ” ν”½μ…€λ‘œ κ΅¬μ„±λ˜μ–΄ 있으며, 각 픽셀은 ν–‰(row)κ³Ό μ—΄(column)의 인덱슀둜 ν‘œν˜„
  • 일반적으둜 μ™Όμͺ½ 상단 λͺ¨μ„œλ¦¬κ°€ (0, 0)으둜 μ‹œμž‘ν•˜μ—¬ 였λ₯Έμͺ½μœΌλ‘œ 갈수둝 μ—΄(column)이 μ¦κ°€ν•˜κ³  μ•„λž˜λ‘œ 갈수둝 ν–‰(row)이 증가

 

 

ꡬ면 μ’Œν‘œκ³„(Spherical Coordinates)

  • ꡬ면 μ’Œν‘œκ³„λŠ” 이미지 μ²˜λ¦¬μ—μ„œ 주둜 μ‚¬μš©λ˜μ§€λŠ” μ•Šμ§€λ§Œ, 컴퓨터 λΉ„μ „μ˜ νŠΉμ • λΆ„μ•Όμ—μ„œ μ‚¬μš©λ  수 있음
  • 주둜 3D κ³΅κ°„μ—μ„œ μ‚¬μš©λ˜λ©°, μœ„λ„(latitude), 경도(longitude), 고도(altitude)와 같은 μ’Œν‘œλ₯Ό μ‚¬μš©ν•˜μ—¬ 지ꡬ ν‘œλ©΄μ„ λ‚˜νƒ€λƒ„
  • νšŒμ „ 및 λ°©ν–₯을 λ‹€λ£¨λŠ” 데 μœ μš©ν•˜λ©°, μΉ΄λ©”λΌμ˜ μœ„μΉ˜ 및 λ°©ν–₯을 μ •ν™•ν•˜κ²Œ μΆ”μ ν•˜λŠ” 데 μ‚¬μš©λ  수 있음
  • 예λ₯Ό λ“€μ–΄, μ΄λ―Έμ§€μ˜ νŠΉμ§•μ μ„ κ°μ§€ν•˜κ³  μΆ”μ ν•˜λŠ” μž‘μ—…μ—μ„œλŠ” 직각 μ’Œν‘œκ³„κ°€ 주둜 μ‚¬μš©λ˜μ§€λ§Œ, 3D 객체의 μœ„μΉ˜ 및 λ°©ν–₯을 μΆ”μ •ν•˜λŠ” μž‘μ—…μ—μ„œλŠ” ꡬ면 μ’Œν‘œκ³„κ°€ μ‚¬μš©λ  수 있음

μ§κ°μ’Œν‘œκ³„ → κ΅¬λ©΄μ’Œν‘œκ³„ μ’Œν‘œ λ³€ν™˜

 

 

κ΅¬λ©΄μ’Œν‘œκ³„ → μ§κ°μ’Œν‘œκ³„ μ’Œν‘œ λ³€ν™˜

 

 

μ½”λ“œ μ˜ˆμ‹œ

import math

# 직각 μ’Œν‘œκ³„μ—μ„œ ꡬ면 μ’Œν‘œκ³„λ‘œ λ³€ν™˜ν•˜λŠ” ν•¨μˆ˜
def rectangular_to_spherical(x, y, z):
    # ꡬ의 λ°˜μ§€λ¦„ 계산
    r = math.sqrt(x**2 + y**2 + z**2)
    # μœ„λ„ 계산
    phi = math.acos(z / r)
    # 경도 계산
    theta = math.atan2(y, x)
    return phi, theta

# ꡬ면 μ’Œν‘œκ³„μ—μ„œ 직각 μ’Œν‘œκ³„λ‘œ λ³€ν™˜ν•˜λŠ” ν•¨μˆ˜
def spherical_to_rectangular(phi, theta, r):
    # 직각 μ’Œν‘œ x, y, z 계산
    x = r * math.sin(phi) * math.cos(theta)
    y = r * math.sin(phi) * math.sin(theta)
    z = r * math.cos(phi)
    return x, y, z

# μ˜ˆμ‹œ: 직각 μ’Œν‘œ (1, 1, 1)λ₯Ό ꡬ면 μ’Œν‘œλ‘œ λ³€ν™˜
rectangular_x = 1
rectangular_y = 1
rectangular_z = 1
phi, theta = rectangular_to_spherical(rectangular_x, rectangular_y, rectangular_z)
print("ꡬ면 μ’Œν‘œ (phi, theta):", phi, theta)

# μ˜ˆμ‹œ: ꡬ면 μ’Œν‘œ (pi/4, pi/4)λ₯Ό 직각 μ’Œν‘œλ‘œ λ³€ν™˜
spherical_phi = math.pi / 4  # 45도
spherical_theta = math.pi / 4  # 45도
radius = 1  # μ˜ˆμ‹œλ‘œ λ°˜μ§€λ¦„μ„ 1둜 κ°€μ •
x, y, z = spherical_to_rectangular(spherical_phi, spherical_theta, radius)
print("직각 μ’Œν‘œ (x, y, z):", x, y, z)
λ°˜μ‘ν˜•