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

but if view img_with_gt looks correct.

even works gt_pane

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
Post a Comment