python - how to stop numpy hstack from changing pixel values in opencv -


i'm trying image display in python using opencv, side pane on it. when use np.hstack main picture becomes unrecognizably white small amount of color. here's code:

    img = cv2.imread(filename)     img_with_gt, gt_pane = evaluator.return_annotated(img, annotations)     both = np.hstack((img_with_gt, gt_pane))      cv2.imshow("moo", both)     cv2.waitkey(0)     cv2.destroyallwindows() 

and here resulting picture

corrupted hstack image

but if view img_with_gt looks correct.

groundtruth correct

even works gt_pane

gt pane correct

i can't seem figure out why happening.

the way can see happening if data types between 2 images don't agree. make sure inside return_annotated method, both img_with_gt , gt_pane both share same data type.

you mentioned fact you're allocating space gt_pane float64. represents intensities / colours within span of [0-1]. convert image uint8 , multiply result 255 ensure compatibility between 2 images. if want leave image untouched , work on classification image (the right one), convert float64 divide 255.

however, if want leave method untouched, simple fix can be:

both = np.hstack(((255*img_with_gt).astype(np.uint8), gt_pane)) 

you can go other way around:

both = np.hstack((img_with_gt, gt_pane.astype(np.float64)/255.0)) 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -