python crop图片 && 将灰度图或者彩图转成二进制文件
import cv2
import numpy as np
img = cv2.imread("140_pre_img.jpg", cv2.IMREAD_GRAYSCALE)
region = img[284:335, 448: 520]
cv2.imwrite('2.jpg', region)
region.tofile(open("1.BIN", 'wb'))
-------------------------------------------------------------------------------------
import cv2
import numpy as np
x = cv2.imread("lane.jpg")
x.tofile(open("1.BIN", 'wb'))