[ Foro de Python ]

TypeError: unsupported operand type(s) for /: 'list' and 'int'

03-Oct-2016 00:22
Invitado (zil99)
1 Respuestas

Hola, estoy recorriendo una matriz por mascaras y me marca este error:
TypeError: unsupported operand type(s) for /: 'list' and 'int'

Este es el código
import cv2
import numpy as np
from PIL import Image
from numpy import array


imagen=Image.open('imagenes/face2.bmp')
width,height=imagen.size
imagen_nueva=Image.new("RGB",(width,height),"white")
imagen_nueva.save('imagenes/face2_nueva.bmp')


#coordenadas=x,y=21,30
#print (imagen.getpixel(coordenadas))
for w in range(width-2):
  for j in range(height-2):
      sum=0
      for ww in range(2):
          for jj in range(2):
              sum=[w+ww-1,j+jj-1]
              imagen_nueva[w,w[2]]=([w+ww-1,j+jj-1])/9 //aquí marca el error


04-Oct-2016 16:02
Nacho Cabanes (+83)

Pide a tu programa que te muestre los valores de las variables en pantalla, porque veo posibles problemas por ahí. Por ejemplo, cuando w=0 y ww=0, w+ww-1 valdrá -1, que en general puede no ser un índice válido.






(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)