예제 #1
0
	cv2.imwrite("imagenes/imgSinColorearParam.jpg",rgb)
	segmentarImagen('imagenes/imgSinColorearParam.jpg')
	break
else:
    break

cv2.waitKey()
capture.read()
cv2.imshow()

capture.release()
cv2.destroyWindow("Captura")

# Si deseas mostrar la imagen con funciones de matplotlib posiblemente haya que cambiar
# el formato, con
cv2.cvtColor(<img>, ...)

# Esta funcion del paquete "select_pixels" pinta los pixeles en la imagen 
# Puede ser util para el entrenamiento

markImg = sel.select_fg_bg(imNp)

# Tambien puedes mostrar imagenes con las funciones de matplotlib
plt.imshow(markImg)
plt.show()

# Si deseas guardar alguna imagen ....

imsave('lineaMarcada.png',markImg)

예제 #2
0

capture = cv2.VideoCapture('./video.mp4')

hsImages = np.memmap('./datasets/hsImages.driver', dtype='uint8', mode='w+', shape=(config.numberOfImages, config.imageShape['height'], config.imageShape['width'], 2))
markedImages = np.memmap('./datasets/markedImages.driver', dtype='uint8', mode='w+', shape=(config.numberOfImages, config.imageShape['height'], config.imageShape['width'], 3))

for i in range(config.numberOfImages):
    print(i)

    # cImg = 0
    key = 0
    while (key != 27):
        ret, im = capture.read()

        cv2.imshow('Camera', im)
        
        key = cv2.waitKey(35)

    cv2.destroyWindow('Camera')
    cv2.waitKey(1)
    cv2.waitKey(1)
    cv2.waitKey(1)
    rgbImg = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
    markedImg = sel.select_fg_bg(rgbImg)

    hsImages[i] = cv2.cvtColor(rgbImg, cv2.COLOR_RGB2HSV)[:,:,(0,1)]
    markedImages[i] = markedImg

hsImages.flush()
markedImages.flush()
예제 #3
0
# Vision por Computador. Master en Inteligencia Artificial
#################################


import numpy as np
from scipy.misc import imread
import maxflow
import matplotlib.pyplot as plt
import select_pixels as sel

imgName='horse.jpg'

img = imread(imgName)

# Marco algunos pixeles que pertenecen el objeto y el fondo
markedImg = sel.select_fg_bg(img)

# Create the graph.
g = maxflow.Graph[float]()

# Add the nodes. nodeids has the identifiers of the nodes in the grid.
nodeids = g.add_grid_nodes(img.shape[:2])

# Calcula los costes de los nodos no terminales del grafo

# Estos son los costes de los vecinos horizontales
exp_aff_h=
# Estos son los costes de los vecinos verticales
exp_aff_v=

# Construyo el grafo 
예제 #4
0
def segmentarImagen(imagen, strn):
    #Colorear Imagen
    i = cv2.imread(imagen)
    imgColoreada = select_fg_bg(i)
    imsave("imagenes/imagenColoreada" + strn + ".png", imgColoreada)