# resize the mask and class map such that its dimensions match the # original size of the input image (we're not using the class map # here for anything else but this is how you would resize it just in # case you wanted to extract specific pixels/classes) mask = cv2.resize(mask, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_NEAREST) classMap = cv2.resize(classMap, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_NEAREST) # perform a weighted combination of the input image with the mask to # form an output visualization output = ((0.4 * image) + (0.6 * mask)).astype("uint8") # show the input and output images cv2.imshow("Legend", legend) cv2.imshow("Input", image) cv2.imshow("Output", output) cv2.waitKey(0)