# Licensed under the MIT License
import numpy as np
from PIL import Image
def stereo_match(left_img, right_img, kernel, max_offset):
# Load in both images, assumed to be RGBA 8bit per channel images
left_img = Image.open(left_img).convert('L')
left = np.asarray(left_img)
right_img = Image.open(right_img).convert('L')
right = np.asarray(right_img)
w, h = left_img.size # assume that both images are same size
# Depth (or disparity) map
depth = np.zeros((w, h), np.uint8)
depth.shape = h, w
kernel_half = int(kernel / 2)
offset_adjust = 255 / max_offset # this is used to map depth map output to 0-255 range
for y in range(kernel_half, h - kernel_half):
print(".", end="", flush=True) # let the user know that something is happening (slowly!)
for x in range(kernel_half, w - kernel_half)
双目立体视觉的SSD立体匹配matlab代码
最新推荐文章于 2024-09-14 09:49:05 发布
本文介绍了使用SSD(Sum of Squared Differences)算法进行双目立体视觉匹配的Matlab实现过程,详细探讨了关键步骤和技术细节,为理解和实践立体视觉提供了基础。
摘要由CSDN通过智能技术生成