Last active
March 5, 2018 14:39
-
-
Save bafu/cf269dae0ce8999b0c52ce70d664b52a to your computer and use it in GitHub Desktop.
Display RGB values in image's pixels
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
#!/usr/bin/python3 | |
# Display RGB values in image's pixels. | |
import sys | |
import cv2 | |
def main(): | |
fpath = sys.argv[1] | |
im = cv2.cvtColor(cv2.imread(fpath), cv2.COLOR_BGR2RGB) | |
h, w, c = im.shape | |
print('(x, y) R G B') | |
for i in range(h): | |
for j in range(w): | |
print('(%3d, %3d) %3d, %3d, %3d' % (j, i, | |
im[i][j][0], | |
im[i][j][1], | |
im[i][j][2])) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment