Está en la página 1de 29

MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS

Nombre del Proceso:


CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

INFORME LABORATORIO DE HERRAMIENTAS MATEMÁTICAS BÁSICAS UTILIZADAS EN


EL PROCESAMIENTO DE IMÁGENES DIGITALES No 1
I
Grupo n 1. Laura Natalia Hernández Vela 4. Nota
t
e 2. Andres Ricardo Parra 5.
g
r
A2 a
n 3. 6.
t
e
s
Resultados obtenidos

SEASON I
CÓDIGO:

from google.colab import drive

drive.mount('/content/drive')

txt_path = 'drive/MyDrive/colab/'

!pip install pydicom

import pydicom as dcm

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.image as image


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

#user defined functions

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

img_log = np.log(1 + img)

img_neg = max_val - img

# 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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

# plots image

fig, ax = plt.subplots (2,2)

ax[0,0].imshow(img, cmap = 'gray')

ax[0,1].imshow(img_neg, cmap = 'gray')

ax[1,1].imshow(img_gam, cmap = 'gray')

ax[1,0].imshow(img_log, cmap = 'gray')

plt.savefig(txt_path+'bassic_transforms_guia1')

plt.show()

IMAGEN RESULTADO

FIGURA1. imagen sesión 1 guia 1


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

SEASON II
CÓDIGO
from google.colab import drive

drive.mount('/content/drive')

txt_path = 'drive/MyDrive/colab/'

!pip install pydicom

import pydicom as dcm

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.image as image

# 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 = 255*((img-min_val)/(max_val - min_val))

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

# negative_tranform

img_neg = obj_dcm.pixel_array

max_val = np.max(img_nrm)

img_neg = max_val - img_nrm

img_neg = (np.around(img_neg)).astype('uint8')

# log_tranform

img_log = np.log(1 + img)

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):

H = np.zeros(256, dtype = int)

for k in range (256):

img_vec = data.flatten()

temp = (img_vec == k).astype('int')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

# acommulate

def perform_acummulate(H):

C =np.zeros(256, dtype=int);

for m in range(256):

temp = 0

for k in range(m):

temp = temp + H[k]

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

#plots results

plt.figure(1)

plt.imshow(img_nrm, cmap = 'gray')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

plt.figure(4)

plt.imshow(img_equ, cmap = 'gray')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

plt.figure(7)

plt.imshow(img_neg, cmap = 'gray')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

plt.figure(10)

plt.imshow(img_log, cmap = 'gray')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

plt.figure(13)

plt.imshow(img_gam, cmap = 'gray')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

IMÁGENES RESULTADOS fgh


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

* SEASON III
# guardar en google drive

from google.colab import drive

drive.mount('/content/drive')

txt_path ='drive/MyDrive/colab/'

!pip install pydicom

import pydicom as dcm

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.image as image

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

#load dcm medical image

obj_dcm = dcm.dcmread (txt_path+'I2')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

# negative_tranform

img_neg = obj_dcm.pixel_array

max_val = np.max(img)

# log_tranform

img_log = np.log(1 + img)

img_neg = max_val - img

img_log = (np.around(img_log)).astype('uint8')

# gamma_correction

gamma = 2.2

img_gam = (img/max_val)**gamma

#rotation

height, width = img.shape[:2]

center = (img.shape[1]//2+10, img.shape[1]//2-10)

angle = 45

scale = 1

rot_mat = cv.getRotationMatrix2D( center, angle, scale )

dst = cv.warpAffine(img,rot_mat,(height,width))

height1, width1 = img_neg.shape[:2]


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

center1 = (img_neg.shape[1]//2+10, img_neg.shape[1]//2-10)

angle1 = 30

scale1 = 0.5

rot_mat1 = cv.getRotationMatrix2D( center1, angle1, scale1 )

dst1 = cv.warpAffine(img_neg,rot_mat1,(height1,width1))

height2, width2 = img_log.shape[:2]

center2 = (img_log.shape[1]//2+25, img_log.shape[1]//2-45)

angle2 = 180

scale2 = 0.8

rot_mat2 = cv.getRotationMatrix2D( center2, angle2, scale2 )

dst2 = cv.warpAffine(img_log,rot_mat2,(height2,width2))

height3, width3 = img_gam.shape[:2]

center3 = (img_gam.shape[1]//2+5, img_gam.shape[1]//2-23)

angle3 = 130

scale3 = 1.3

rot_mat3 = cv.getRotationMatrix2D( center3, angle3, scale3 )

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

plt.imshow(dst,cmap = 'gray')

plt.title('Normal 45 grados')

plt.savefig(txt_path+'prueba1')

plt.show()

plt.imshow(dst1,cmap = 'gray')

plt.title('reducido negativa a 30°')

plt.savefig(txt_path+'prueba2')

plt.show()

plt.imshow(dst2,cmap = 'gray')

plt.title('reducido logaritmo 180° trasladada')

plt.savefig(txt_path+'prueba3')

plt.show()

plt.imshow(dst3,cmap = 'gray')

plt.title('aumentada gamma 130° trasladada')

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

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

RESULTADOS

FIGURA2. IMAGEN NORMAL.

FIGURA3. IMAGEN REDUCIDA A LA MITAD


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

FIGURA4. IMAGEN REDUCIDA EL TRIPLE.

FIGURA5. IMAGEN REDUCIDA EL CUÁDRUPLE.


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

FIGURA6. IMAGEN AUMENTADA EL DOBLE.

FIGURA7. IMAGEN AUMENTADA EL TRIPLE.


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

FIGURA8. IMAGEN AUMENTADA EL CUÁDRUPLE.

FIGURA9. IMAGEN ROTACIÓN 60°.


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

FIGURA10. IMAGEN ROTADA 150° Y AUMENTADA EL DOBLE

FIGURA11. IMAGEN ROTACIÓN, TRASLACIÓN, REDUCCIÓN.


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

FIGURA12. IMAGEN, ROTACIÓN. TRASLACIÓN, REDUCCIÓN.


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021


MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

Análisis e interpretación de resultados


IN THIS GUIDE WE EVIDENCE THAT THE PYTHON TOOL IS VERY COMPLEX
BECAUSE IT ALLOWS US TO UPLOAD IMAGES IN .DCM FORMAT, WHICH ALLOWS
US TO MAKE A SERIES OF ARRANGEMENTS, EITHER TO IMPROVE THEIR
SHARPNESS, CREATE NEW FILTERS OR SIMPLY ELIMINATE NOISES, THESE
PARTICULAR FUNCTIONS IN THE IMAGES THEY ALLOW US TO MAKE A GOOD
DIAGNOSIS SINCE THROUGH ARRANGEMENTS AND CODES WE CAN SEE
DIFFERENT PATHOLOGIES WITH GREATER CLARITY IN DIFFERENT IMAGE
SPECTRUM THE HISTOGRAM GRAPHICS.

Conclusiones

● TO BE ABLE TO DISPLAY AN IMAGE THAT IS OUTSIDE THE PARAMETERS, IT IS


NECESSARY TO PARAMETERIZE IT WITH THE 'UNIT8' FUNCTION, WHICH ALLOWS US
TO DISPLAY THE IMAGE AS WELL AS ITS HISTOGRAMS, OTHERWISE THIS TYPE OF
PARAMETERIZATION IS DONE, THE SAFEST IS THAT THE PLATFORM SHOWS US A
ERROR.
● IT IS NECESSARY TO TAKE INTO ACCOUNT THE SPACES AND THE CLOSURE OF THE
CYCLES BECAUSE IF THE PRIORITY OF THE FUNCTIONS IS NOT TAKEN INTO
ACCOUNT, AN ERROR CAN BE MADE AS WELL AS IN THE DEFINITION OF VARIABLES,
THEY NEED TO BE ON THE SAME CODE SPACE.
● YOU CAN MAKE FILTERS, NOISE REMOVAL, ROTATE, ENLARGE AND REDUCE AN
IMAGE USING THE APPROPRIATE CODE ALSO YOU CAN MANIPULATE ITS DIFFERENT
SPECTRUM.
MACROPROCESO RECURSOS E INFRAESTRUCTURA Y LABORATORIOS
Nombre del Proceso:
CODIGO: LA-FM-007
GESTIÓN DE LABORATORIOS
Nombre del Documento: VERSION: 6

FORMATO PRÁCTICAS DE LABORATORIOS FECHA: 16/noviembre/2021

● 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.

También podría gustarte