Answer to StackOverflow Question: Problem in returning images in Python for LabVIEW
Last active
July 25, 2022 21:10
-
-
Save j-medland/2268dc11f64deb0daa4d415c96f27233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
def threshold(data): | |
gray = np.array(data,dtype=np.uint8) | |
# perform threshold operation | |
ret, thresh1 = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY) | |
# | |
# create an RGB image to demonstrate output | |
# | |
height = 200 | |
width = 300 | |
rgb = np.zeros((height,width,3), np.uint8) | |
# create RGB verticle stripes | |
# note cv2 channels are arranged BGR | |
# red stripe | |
rgb[:,0:width//3] = (0,0,255) | |
# green stripe | |
rgb[:,width//3:2*width//3] = (0,255,0) | |
# blue stripe | |
rgb[:,2*width//3:width] = (255,0,0) | |
# return rgb 3d-array | |
return rgb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment