LINUX.ORG.RU

Ошибка «label() got an unexpected keyword argument 'neighbors'» 'это стандратная строка, библиотека тоже работает почему у меня ошибка?

 ,


0

0

Работаю над кодом с использованием Open CV. Не понимаю почему у меян ошибка в стандартной строке(labels = measure.label(thresh, neighbors=8, background=0) а именно «Exception has occurred: TypeError label() got an unexpected keyword argument ‘neighbors’» )

import numpy as np
import argparse
import cv2
import imutils
from imutils import contours
import skimage
from skimage import measure
import argparse

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image file")
ap.add_argument("-r", "--radius", type = int,
	help = "radius of Gaussian blur; must be odd")
args = vars(ap.parse_args())
# load the image and convert it to grayscale
#image = cv2.imread(args["image"])
image = cv2.imread("2.jpg")

#image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (11, 11), 0)
thresh = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.erode(thresh, None, iterations=2)
thresh = cv2.dilate(thresh, None, iterations=4)
#print(image)

labels = measure.label(thresh, neighbors=8, background=0)
mask = np.zeros(thresh.shape, dtype="uint8")
# loop over the unique components
for label in np.unique(labels):
	#if this is the background label, ignore it
	if label == 0:
		continue
	# otherwise, construct the label mask and count the
	# number of pixels 
	labelMask = np.zeros(thresh.shape, dtype="uint8")
	labelMask[labels == label] = 255
	numPixels = cv2.countNonZero(labelMask)
	# if the number of pixels in the component is sufficiently
	# large, then add it to our mask of "large blobs"
	if numPixels > 300:
		mask = cv2.add(mask, labelMask)
		cv2.imshow("Image", image)
		cv2.waitKey(0)

Заранее спасибо!

Перемещено xaizek из general

Перемещено leave из linux-install



Последнее исправление: katemisik (всего исправлений: 5)

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.