我开始使用openCV&正在使用Python book编写计算机视觉编程。似乎我有一个默认值,设置为相反(或相反?)因为我电脑上的图像是黑色的,而书中的图像是白色的。在
有没有办法设置默认值,使其在每次都不进行计算的情况下翻转黑白?在
这是本书中的一些示例代码。在书中,背景是白色的,但在我的电脑上,它是黑色的:from PIL import Image
from numpy import *
from scipy.ndimage import filters
im = array(Image.open('empire.jpg').convert('L'))
sigma = 5
imx = zeros(im.shape)
filters.gaussian_filter(im,(sigma,sigma),(0,1),imx)
imy = zeros(im.shape)
filters.gaussian_filter(im,(sigma,sigma),(1,0),imy)
magnitude = sqrt(imx**2+imy**2)
figure()
subplot(1,4,1)
imshow(im)
subplot(1,4,2)
imshow(imx)
subplot(1,4,3)
imshow(imy)
subplot(1,4,4)
imshow(magnitude)
我在macbookpro上使用python2.7。这可能在某个地方得到了答案,但我找不到答案-可能没有使用正确的标签/关键字。。。提前支付。在