Documentos de Académico
Documentos de Profesional
Documentos de Cultura
SEASON I
CÓDIGO:
drive.mount('/content/drive')
txt_path = 'drive/MyDrive/colab/'
import numpy as np
def perform_normalize(data):
min_val = np.min(data);
max_val = np.max(data);
new_data = (data-min_val)/(max_val-min_val)
return new_data
# up image
obj_dcm =
dcm.dcmread(txt_path+'1.3.6.1.4.1.5962.99.1.2786334768.1849416866.1385765836
848.2.0.dcm')
img = perform_normalize(obj_dcm.pixel_array)
# negative_tranform
img_neg = obj_dcm.pixel_array
max_val = np.max(img)
# log_tranform
# gamma_correction
gamma = 2.2
img_gam = (img/max_val)**gamma
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
# plots image
plt.savefig(txt_path+'bassic_transforms_guia1')
plt.show()
IMAGEN RESULTADO
SEASON II
CÓDIGO
from google.colab import drive
drive.mount('/content/drive')
txt_path = 'drive/MyDrive/colab/'
import numpy as np
# up image
obj_dcm =
dcm.dcmread(txt_path+'1.3.6.1.4.1.5962.99.1.2786334768.1849416866.13857
65836848.2.0.dcm')
img = obj_dcm.pixel_array
#normalize image
min_val = np.min(img);
max_val = np.max(img);
img_nrm = (np.around(img_nrm)).astype('uint8')
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
# negative_tranform
img_neg = obj_dcm.pixel_array
max_val = np.max(img_nrm)
img_neg = (np.around(img_neg)).astype('uint8')
# log_tranform
img_log = (np.around(img_log)).astype('uint8')
# gamma_correction
gamma = 2.2
img_gam = (img_nrm/max_val)**gamma
img_gam = (np.around(img_gam)).astype('uint8')
# histogram
def perform_histogram(data):
img_vec = data.flatten()
H[k] = np.sum(temp)
return H
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
# acommulate
def perform_acummulate(H):
C =np.zeros(256, dtype=int);
for m in range(256):
temp = 0
for k in range(m):
C[m] = temp
return C
# image dimensions
M, N = img_nrm.shape
H = perform_histogram(img_nrm)
C = perform_acummulate(H)
#equalization
img_equ = np.zeros((M,N))
for i in range(M):
for j in range(N):
r = img_nrm[i,j]
img_equ[i,j] = C[r]*(256/(M*N)) -1
img_equ = (np.around(img_equ)).astype('uint8')
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
#plots results
plt.figure(1)
plt.title('Original')
plt.colorbar()
plt.axis('off')
plt.savefig(txt_path+'SESION2_guia1_NORM')
plt.show()
plt.figure(2)
plt.title('histogram')
plt.plot(perform_histogram(img_nrm))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_NORMH')
plt.show()
plt.figure(3)
plt.title('acummulate')
plt.plot(perform_acummulate(perform_histogram(img_nrm)))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_NORMA')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
plt.figure(4)
plt.title('Equalized Image')
plt.colorbar()
plt.axis('off')
plt.savefig(txt_path+'SESION2_guia1_EQU')
plt.show()
plt.figure(5)
plt.plot(perform_histogram(img_equ))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_EQUH')
plt.show()
plt.figure(6)
plt.plot(perform_acummulate(perform_histogram(img_equ)))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_EQUA')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
plt.figure(7)
plt.title('Negative_Image')
plt.colorbar()
plt.axis('off')
plt.savefig(txt_path+'SESION2_guia1_NEG')
plt.show()
plt.figure(8)
plt.plot(perform_histogram(img_neg))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_NEGH')
plt.show()
plt.figure(9)
plt.plot(perform_acummulate(perform_histogram(img_neg)))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_NEGA')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
plt.figure(10)
plt.title('LOGARITMO')
plt.colorbar()
plt.axis('off')
plt.savefig(txt_path+'SESION2_guia1_LOG')
plt.show()
plt.figure(11)
plt.plot(perform_histogram(img_log))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_LOGH')
plt.show()
plt.figure(12)
plt.plot(perform_acummulate(perform_histogram(img_log)))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_LOGA')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
plt.figure(13)
plt.title('GAMMA')
plt.colorbar()
plt.axis('off')
plt.savefig(txt_path+'SESION2_guia1_GAM')
plt.show()
plt.figure(14)
plt.plot(perform_histogram(img_gam))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_GAMH')
plt.show()
plt.figure(15)
plt.plot(perform_acummulate(perform_histogram(img_gam)))
plt.grid('on')
plt.savefig(txt_path+'SESION2_guia1_GAMA')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
* SEASON III
# guardar en google drive
drive.mount('/content/drive')
txt_path ='drive/MyDrive/colab/'
import numpy as np
import cv2 as cv
def perform_normalize(data):
min_val=np.min(data);
max_val = np.max(data);
new_data = (data-min_val)/(max_val-min_val)
new_data = (np.around(255*new_data)).astype('uint8')
return new_data
img=perform_normalize(obj_dcm.pixel_array)
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
# negative_tranform
img_neg = obj_dcm.pixel_array
max_val = np.max(img)
# log_tranform
img_log = (np.around(img_log)).astype('uint8')
# gamma_correction
gamma = 2.2
img_gam = (img/max_val)**gamma
#rotation
angle = 45
scale = 1
dst = cv.warpAffine(img,rot_mat,(height,width))
angle1 = 30
scale1 = 0.5
dst1 = cv.warpAffine(img_neg,rot_mat1,(height1,width1))
angle2 = 180
scale2 = 0.8
dst2 = cv.warpAffine(img_log,rot_mat2,(height2,width2))
angle3 = 130
scale3 = 1.3
dst3 = cv.warpAffine(img_gam,rot_mat3,(height3,width3))
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
plt.imshow(dst,cmap = 'gray')
plt.title('Normal 45 grados')
plt.savefig(txt_path+'prueba1')
plt.show()
plt.imshow(dst1,cmap = 'gray')
plt.savefig(txt_path+'prueba2')
plt.show()
plt.imshow(dst2,cmap = 'gray')
plt.savefig(txt_path+'prueba3')
plt.show()
plt.imshow(dst3,cmap = 'gray')
plt.savefig(txt_path+'prueba4')
plt.show()
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6
RESULTADOS
Conclusiones
● Enumerate the different methods to modify the spatial resolution of an image, make a short explanation of
each method.
the method to rotate the image is 'cv.getRotationMatrix2D' which is made up of 3 variables in its
syntax; these are, center, angle and scale with this method we can change the values of the
different variables, but before this a parameterization must be done with the 'cv.warpAffine'
method which allows us to standardize the image in its height and width for better visualize the
change made to the image.