Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
- im=mpimg.imread("./imagenormal.png")
- imList=im.tolist()
- hauteur=len(imList)
- print("hauteur = " + str(hauteur))
- largeur=len(imList[0]) # première ligne
- print("largeur = " + str(largeur))
- def teinte(R,G,B):
- Max = max([R,G,B])
- Min = min([R,G,B])
- if Max == Min:
- return 0
- elif Max == R:
- return 60 *((G-B)/(Max-Min)) + 360
- elif Max == G :
- return 60 *((B-R)/(Max-Min)) + 120
- elif Max == B:
- return 60 *((R-G)/(Max-Min))+ 240
- def saturation(R,G,B):
- if max([R,G,B]) == 0 :
- return 0
- else :
- return 1 - (min([R,G,B])/max([R,G,B]))
- def luminance(R,G,B):
- return max([R,G,B])
- for i in range(0,hauteur) : # i nb ligne
- for j in range(largeur) : # j nb colonne
- pixel =imList[i][j]
- r = pixel[0]
- g = pixel[1]
- b = pixel[2]
- plt.savefig('test.png')
- plt.imshow(im,cmap='gray')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement