import cv2
import numpy as np
import os
im = cv2.imread("lamp1.jpg")
sp = im.shape
sz1 = sp[0]#height(rows) of image
sz2 = sp[1]#width(colums) of image
sz3 = sp[2]#the pixels value is made up of three primary colors
图像大小
if(sz2>4000 and sz2<6000):
Wth = sz2/2
Ht = sz1/2
elif(sz2>6000 and sz2<9000):
Wth = sz2/3
Ht = sz1/3
else:
Wth = sz2
Ht = sz1
灰度
image = cv2.resize(im,(Wth,Ht),interpolation=cv2.INTER_CUBIC) #resize 1500,1000
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#cv2.imshow("Image", image)
Sobel算子
gradX = cv2.Sobel(gray, ddepth=cv2.cv.CV_32F, dx=1, dy=0, ksize=-1)
gradY = cv2.Sobel(gray, ddepth=cv2.cv.CV_32F, dx=0, dy=1, ksize=-1)
# subtract the y-gradient from the x-gradient
gradi

最低0.47元/天 解锁文章
9491

被折叠的 条评论
为什么被折叠?



