forked from redavids/IBTCDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGBValues.py
More file actions
43 lines (36 loc) · 1.7 KB
/
RGBValues.py
File metadata and controls
43 lines (36 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 7 19:41:22 2016
@author: Chris
"""
from scipy import misc
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
np.set_printoptions(threshold=np.inf)
#image=misc.imread('C:\\Users\\Chris\\Downloads\\checkerboard.jpg')
image=misc.imread('C:\\Users\\Chris\\Downloads\\small kazak.jpg') #We have a problem here. Because of how we set up the code, this lines requires us to either
#change the file name in the directory to match this or we have to edit the code to match
#the file name in the directory.
#print (image[0])
#plt.imshow(image) #Loads Image
#plt.show() #Shows the image window
#average method
def average(pixel):
return (pixel [0] + pixel [1] + pixel [2])/3
#luminosity method
#def modedversion(pixel):
#return (0.21*pixel [0] + 0.72*pixel [1] + 0.07*pixel [2])
grey = np.zeros((image.shape[0], image.shape[1]))
for rownum in range(len(image)):
for colnum in range(len(image[rownum])):
grey[rownum][colnum] = average(image[rownum][colnum])
#use line below when running modedversion function for our code
#grey[rownum][colnum] = modedversion(image[rownum][colnum])
plt.imshow(grey, cmap = cm.Greys_r)
plt.show() #This pushes out the image that we use in the other block of code to anaylzse for persistent pairs
#image=misc.imread('C:\\Users\\Chris\\Downloads\\cat.jpg')
#print(image) #Gives the RGB values for all pixels. The Inner most brackers give the RGB values for the rows
#print (image.shape) #Gives the height and width of the image
#print (image[0]) #Gives RGB values for row 0
#print (image[0][0]) #Gives RGB values for row 0 and column 0