0
0

複数画像の平均を求める

Last updated at Posted at 2024-06-21

画像内の物体を検出する際に動くもの(人,車など)を削除(薄くする)することができる.

画像を追加する予定です.

# 画像を読み込み配列に入れる
def read_images(filenames):
  images = []
  for filename in filenames:
    img = cv2.imread(filename)
    images.append(img)
  return images

# 画像の平均を求める
def average_images(images):
  num_images = len(images)
  if num_images == 0:
    return None
  total_image = np.zeros(images[0].shape, dtype=np.float32)
  for img in images:
    total_image += img.astype(np.float32)
  average_image = total_image / num_images
  return average_image.astype(np.uint8)

if __name__ == "__main__":
  # 画像ファイルのパス
  filenames = [img1, img2, img3]  
  
  images = read_images(filenames)
  average_image = average_images(images)
  cv2.imshow(average_image)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0