Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

TypeError: only size -1 arrays can be converted to python scalar

$
0
0
i am facing this error and am new to python. not sure how am not supposed to enter a matrix as the input ( image) this is the code : import cv2 import matplotlib.pyplot as plt image = cv2.imread('sample.jpg') def show_rgb_hist(image): colours = ('r','g','b') for i, c in enumerate(colours): plt.figure(figsize=(20, 4)) histr = cv2.calcHist([image], [i], None, [256], [0, 256]) if c == 'r': colours = [((i/256, 0, 0)) for i in range(0, 256)] if c == 'g': colours = [((0, i/256, 0)) for i in range(0, 256)] if c == 'b': colours = [((0, 0, i/256)) for i in range(0, 256)] plt.bar(range(0, 256), histr, color=colours, edgecolor=colours, width=1) plt.show() x=show_rgb_hist(image) cv2.imshow('img', x)

Viewing all articles
Browse latest Browse all 2088

Trending Articles