컴퓨터 비젼(Computer Vision)

이미지에서 black border 제거하기

rongxian 2021. 8. 2. 09:31
image = read_img(i)
temp_image = image

threshold = 0

rows = np.where(np.max(temp_image, 0) > threshold)[0]
if rows.size:
  cols = np.where(np.max(temp_image, 1)>threshold)[0]
  image = image[cols[0]:cols[-1]+1, rows[0]:rows[-1]+1]
else:
  image = image[:1, :1]

return image

 

threshold를 통해  허용 가능한 pixel 조절 가능