LoginSignup
28
20

More than 5 years have passed since last update.

OpenCV(Python)で画像をトリミング

Posted at

Qiita初投稿です.
はてなブログで需要がありそうな記事の移植になりますが.

OpenCV(Python)で画像をトリミング-完全に実力不足な理系大学生からの成長ブログ

OpenCVって簡単なことやりたいのになかなか検索でひっかからなかったりするんですよねー.

toriming.py
import cv2

if __name__ == '__main__':

  #画像入力
    im = cv2.imread('Lena.bmp',0)

    #新しい配列に入力画像の一部を代入
    dst = im[200:400,70:270]

    #書き出し
    cv2.imwrite('cut.bmp',dst)

alt
入力画像

alt
出力画像

pythonだと簡単にできちゃいますね.
以上です.

28
20
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
28
20