【问题标题】:I am getting like SyntaxError: invalid syntax [closed]我越来越喜欢 SyntaxError: invalid syntax [关闭]
【发布时间】:2022-12-05 23:21:06
【问题描述】:

我尝试使用以下代码

import cv2
from google.colab import drive
drive.mount('/content/drive')
image = cv2.imread('/content/drive/MyDrive/dusty.jpg') #reads the image
dst = cv2.fastNlMeansDenoisingColored(image, None, 10, 10, 7, 15)
#the meaning of parameters given
p1 = 10 #size of pixels to compute weights of the image
p2 = 10 #to compute the weighted average
p3 = 7 #filter strength for luminescence
p4 = 15 #filter strength for color component
rgb_image = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)
cv2.imwrite('RGB_/content/drive/MyDrive/dusty.jpg',rgb_image)
new_image = (cv2.medianBlur(rgb_image,5)
> cv2.imwrite('median_blur/content/drive/MyDrive/dusty.jpg',new_image) #error here 
> 
cv2.imwrite('median_blur/content/drive/MyDrive/dusty.jpg',new_image)
    ^
SyntaxError: invalid syntax

【问题讨论】:

标签: python


【解决方案1】:

你忘了关闭new_image = (cv2.medianBlur(rgb_image,5))

import cv2
from google.colab import drive
drive.mount('/content/drive')
image = cv2.imread('/content/drive/MyDrive/dusty.jpg') #reads the image
dst = cv2.fastNlMeansDenoisingColored(image, None, 10, 10, 7, 15)
#the meaning of parameters given
p1 = 10 #size of pixels to compute weights of the image
p2 = 10 #to compute the weighted average
p3 = 7 #filter strength for luminescence
p4 = 15 #filter strength for color component
rgb_image = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)
cv2.imwrite('RGB_/content/drive/MyDrive/dusty.jpg',rgb_image)
new_image = (cv2.medianBlur(rgb_image,5))

【讨论】:

    【解决方案2】:

    在上面的行中,你打开了括号,但没有关闭它......

    new_image = (cv2.medianBlur(rgb_image,5)
    

    做就是了

    new_image = cv2.medianBlur(rgb_image,5)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-12
      • 1970-01-01
      • 2015-06-10
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多