Skip to content

Instantly share code, notes, and snippets.

@PeaceAndHiLight
Last active January 6, 2016 14:16
Show Gist options
  • Save PeaceAndHiLight/ae5d90a5de78b5e8a47c to your computer and use it in GitHub Desktop.
Save PeaceAndHiLight/ae5d90a5de78b5e8a47c to your computer and use it in GitHub Desktop.
Python About ROI
#coding: utf-8
import cv2
import numpy as np
rows = 256
cols = 256
img = np.zeros((rows,cols,3), dtype=np.uint8)
#ここでimgの中身を見てみると??
#print img
#この時点ではまだ真っ黒の画像です
cv2.imshow('black', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
#色の設定
#全部をredでベタ塗りにして、縦方向10から30,横方向50から80までを白で塗りつぶす
img[:,:] = [0, 0, 255]
img[10:30,50:80] = [255, 255, 255]
#保存したいとき
#cv2.imwrite('redandwhite.jpg', img)
#ウィンドウに表示
cv2.imshow('red and white', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment