Skip to content

Instantly share code, notes, and snippets.

@TomoG29
Created March 31, 2024 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomoG29/fab591cfdb90caa6e26853aa313bb8ac to your computer and use it in GitHub Desktop.
Save TomoG29/fab591cfdb90caa6e26853aa313bb8ac to your computer and use it in GitHub Desktop.
import cv2
import glob
import os
import getpass
# 入出力フォルダのパス
import_file = os.path.join("インポートしたい画像のフォルダパス")
export_file = os.path.join("エクスポートしたい画像のフォルダパス")
def main():
# 対象画像のファイルパス取得
files = glob.glob(os.path.join(import_file, '*.png'))
# ファイルごとに処理
for file in files:
# 画像を読み込む
image = cv2.imread(file)
basename = os.path.basename(file)
##
## 処理
##
# 画像を保存
cv2.imwrite(os.path.join(export_file, 'result_' + basename), image)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment