-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImaTratamientoRGB.py
64 lines (49 loc) · 1.64 KB
/
ImaTratamientoRGB.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 26 13:16:20 2018
@author: FamiliaHogar
"""
import matplotlib.pyplot as plt
import numpy as np
import PIL
from skimage import io
colorGirl=io.imread("imaTestColor.jpg")/255.0
print("- Dimensiones de la imagen:")
print(colorGirl.shape)
plt.imshow(colorGirl,vmin=0,vmax=1)
plt.title("RGB")
plt.figure()
plt.imshow(colorGirl[:,:,0],vmin=0,vmax=1)
plt.title("Canal Rojo")
plt.figure()
plt.imshow(colorGirl[:,:,1],vmin=0,vmax=1)
plt.title("Canal Verde")
plt.figure()
plt.imshow(colorGirl[:,:,2],vmin=0,vmax=1)
plt.title("Canal Azul")
plt.figure()
colorGirlRed=np.copy(colorGirl) # creo una copia de la imagen para preservar la original
colorGirlRed[:,:,1]=0 # quito el canal azul
colorGirlRed[:,:,2]=0 # quito el canal verde
plt.title("ColorGirl Canal Rojo")
plt.imshow(colorGirlRed)
#Suavizar imagen gris
plt.figure()
grayGirl=io.imread("imaTestGris.jpg")/255.0
print("- Dimensiones de la imagen:")
print(grayGirl.shape)
plt.imshow(grayGirl,vmin=0,vmax=1)
plt.title("Sin suavizar")
imagen = PIL.Image.open("imaTestGris.jpg").convert("L")
imaMatriz = np.array(imagen)
imaMatrizSuav = np.zeros(imaMatriz.shape)
print(imaMatriz.shape)
for x in range(410):
for y in range(730):
imaMatrizSuav[x,y] = ((imaMatriz[(x+1)%410,y] + imaMatriz[(x+1)%410,(y+1)%730]
+ imaMatriz[x,(y+1)%730] + imaMatriz[x-1,(y+1)%730] + imaMatriz[x-1,y]
+ imaMatriz[x-1,y-1] + imaMatriz[x,y-1] + imaMatriz[(x+1)%410,y-1]
+ imaMatriz[x,y])/10)
plt.figure()
plt.imshow(imaMatrizSuav)
plt.title("Suavizada")