如何解决如何解决此问题[SpyderKernelApp]警告|没有这样的通讯方式:
我刚刚开始了解OpenSV,并在调整图像大小后尝试使其不失真。这是我的代码:
import numpy as np
import cv2
# upload the file as a color image and as a gray image
img = cv2.imread('C:/Users/HomePC/Desktop/1.jpg')
img_gray = cv2.imread('C:/Users/HomePC/Desktop/1.jpg',0)
# display images in a window
cv2.imshow('Window',img)
# all windows are closed after pressing any key
cv2.waitKey (0)
cv2.destroyAllWindows()
# save images to a file
image = cv2.imread('C:/Users/HomePC/Desktop/1.jpg')
cv2.imwrite('C:/Users/HomePC/Desktop/1.png',image)
img = cv2.imread ('C:/Users/HomePC/Desktop/1.jpg')
img = cv2.imread ('C:/Users/HomePC/Desktop/1.jpg',1)
(h,w,d) = image.shape#
print("width ={},height ={},depth ={}". format (w,h,d))
# access to individual pixels
# access to RGB (!) pixels with coordinates x = 50,y = 100
(B,G,R) = image[100,50]
print("R={},G={},B={}". format (R,B))
# slice arrays and cut out images
# extract a 100x100 pixel square ROI ( Region of Interest ) from the
# input image starting at x=320,y=60 at ending at x=420,y= 160
roi = image[560:660,320:420]
cv2.imshow("ROI ",roi)
cv2.waitKey(0)
# resize images
# resize the image to 200x200px,ignoring aspect ratio
resized = cv2.resize(image,(200,200 ))
cv2.imshow("Fixed Resizing ",resized)
cv2.waitKey(0)
img = cv2.imread('C:/Users/HomePC/Desktop/1.jpg')
h,w= img.shape[0:2] # height and width of the original image
h_new = 500 # the height of the new image
ratio =w/h # the ratio of width to height
w_new = int( h_new * ratio) # width of the new image
resized = cv2.resize(img,(w_new,h_new)) # new image,in the cottage width in the first place!
# although the shape function has a height as the first argument
print(resized.shape)
cv2.imshow('1',resized)
当我尝试使图像在调整大小后不失真时,蜘蛛网给了我这个错误:
内核死亡,重新启动
[SpyderKernelApp]警告|没有这样的通讯:a45c4fb203fc11ebaed21831bf76912a
这是在添加以下代码后发生的:
img = cv2.imread('C:/Users/HomePC/Desktop/1.jpg')
h,resized)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。