python - Opencv fillPoly() not working for greyscale (1-channel) images -


so using opencv modify pixel values on 1-channel image. create blank image using

curr = np.zeros((660,512, 1)) 

then execute code:

for r in regions:     cv2.fillpoly(curr, r, [190]) 

where each region looks like:

[[[363 588]   [304 593]   [323 652]   [377 654]]] 

i know code @ least working, because when use imshow(), regions filled desired. however, tried re-accessing modified pixel values, , got [ 0.] tried writing whole img ti temporary file follows:

for elt in curr:     f2.write(str(elt) + '\n') 

however, file looks like

 [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.]  [ 0.] 

where going wrong? why can't re-access 190s wrote image?

works fine.

curr = np.zeros((660,512, 1),dtype = np.uint8)  regions = np.array([[[363,588],[304,593],[323,652],[377,654]]])  r in regions:     cv2.fillpoly(curr, [regions[0]], (190))  # find minimum value, maximum value , location index in image minval,maxval,minloc,maxloc = cv2.minmaxloc(curr)  print(maxval, maxloc) 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -