cv2.line(imgHist, (x, img.shape[0]), (x, img.shape[0]-intensity//255), (255, 0, 255), 1, lineType=8, shift=0)

asked 2020-08-17 01:52:45 -0600

vishnukannan gravatar image

updated 2020-08-22 04:49:56 -0600

berak gravatar image

.

cv2.line(imgHist, (x, img.shape[0]), (x, img.shape[0]-intensity//255), (255, 0, 255), 1, lineType=8, shift=0)

TypeError: only size-1 arrays can be converted to Python scalars
edit retag flag offensive close merge delete

Comments

Why do u have 2 duplicated (x, img.shape[0]), (x, img.shape[0]? Both in same x-axis and same width.

supra56 gravatar imagesupra56 ( 2020-08-18 07:45:49 -0600 )edit
2

the img.shape[0] value is 240 i put the value to my program that was also the same error without cv2.line(imgHist, (x, 240), (x, intensity//255), (255, 0, 255), 1, lineType=8, shift=0) TypeError: only size-1 arrays can be converted to Python scalars

vishnukannan gravatar imagevishnukannan ( 2020-08-18 23:28:30 -0600 )edit

what exactly are x, ìntensity ?

(we cannot help without knowing those, one of them seems to be an array, not a number)

berak gravatar imageberak ( 2020-08-22 04:55:35 -0600 )edit
1

histValues = np.sum(img,axis=0) ... for x, intensity in enumerate(histValues): i just iterate using x and intensity

vishnukannan gravatar imagevishnukannan ( 2020-08-22 07:05:44 -0600 )edit

again, check the types

berak gravatar imageberak ( 2020-08-22 07:28:21 -0600 )edit

R u attempting to draw a line in snooker, billard, etc?

supra56 gravatar imagesupra56 ( 2020-08-22 08:07:44 -0600 )edit

img is a color image, isn't it? then sum(axis=0) only collapses the one dimension and you still have TWO left. please ALWAYS look at your data. learn to use pdb, the python debugger.

crackwitz gravatar imagecrackwitz ( 2020-08-22 16:47:35 -0600 )edit

yeah, now i have to check it

vishnukannan gravatar imagevishnukannan ( 2020-08-25 06:32:28 -0600 )edit