#!/usr/bin/env python
# coding: utf-8

# In[16]:


a=[1,2,3,4]
b=[5,6,7,8]
c=[]
for x in range(4):
    c.append(a[x]*2+b[x])
    print (c[x])
print(c)


# In[3]:


import numpy as np
from matplotlib import pyplot as plt


# In[28]:


a= np.array([1,2,3,4])
b= np.array([5,6,7,8])
c= a*2+b


# In[36]:


a = np.arange(5, 2894, 5)
b = np.arange(5,2893,5)
c=a*2+b
print(c)


# In[51]:


get_ipython().run_line_magic('pinfo', 'cmap')


# In[45]:


dir(plt)


# In[4]:


grey_img=plt.imread('img/bird.png',format='png')
grey_img.shape
#plt.imshow(grey_img[10:100,200:290],cmap='gray')
print(grey_img)


# In[69]:


flatGrey=grey_img.flatten()
plt.hist(flatGrey*255,bins=100)
plt.show()


# In[72]:


filtered_img=grey_img*(grey_img<100)
plt.imshow(filtered_img)


# In[78]:


colorImg=plt.imread('img/onion.jpg',format='jpg')
colorImg


# In[91]:


colorImg[:,:,2]
redImg=colorImg[:,:,0]
greenImg=colorImg[:,:,1]
blueImg=colorImg[:,:,2]


# In[96]:


flatRed=redImg.flatten()
plt.hist(flatRed,bins=50, color='red')
plt.show()
flatGreen=greenImg.flatten()
plt.hist(flatGreen,bins=50, color='green')
plt.show()
flatBlue=blueImg.flatten()
plt.hist(flatBlue,bins=50, color='blue')
plt.show()


# In[133]:


bact=plt.imread('bact/colony_growth_20.tif',format='tif')
plt.imshow(bact,cmap='gray')


# In[124]:


flatBac=bact.flatten()
plt.hist(flatBac,bins=50)


# In[134]:


brilloBacteria=90
normBac=bact/np.max(bact)
filtered=normBac*(normBac>0.5)
numBac=np.sum(normBac>0.5)
print(numBac)
plt.imshow(filtered)


# In[137]:


title1="Bact/colony_growth_"
title2=".tif"
fullTitle=""
bacterias=[]
for x in range(37):
    if x<10:
        fullTitle=title1+"0"+str(x)+title2
    else:
        fullTitle=title1+str(x)+title2
    bact=plt.imread(fullTitle,format='tif')
    normBac=bact/np.max(bact)
    numBac=np.sum(normBac>0.5)
    bacterias.append(numBac)
print(bacterias)1
plt.plot(bacterias)
    


# In[200]:


colonias=plt.imread("img/Colonies.jpg",format="jpg")
colonia=colonias[:270,:280,1]
colNorm=colonia/np.max(colonia)
filtro=colNorm*(colNorm<0.35)
areaBacs=np.sum(colNorm<0.35)
areaTotal=np.sum(colNorm>=0)
areaRelativa=areaBacs/areaTotal*1.0
print(areaBacs)
print(areaTotal)
print(areaRelativa)
plt.imshow(filtro)


# In[140]:


get_ipython().run_line_magic('pinfo', 'plt.Circle')

