내 의도하는 것입니다 :python에서 이미지를 번역하는 방법 PIL? 아래 그림과 같이
http://postimg.org/image/pdb6urf1d/
내 기능 :이 오류가 나타납니다
def translacao(imagem1):
imagem1.save("translate.png")
destino = Image.open("translate.png")
destino = destino.resize((400,400))
#Tamanho Imagem - Largura e Altura
width = destino.size[0]
height = destino.size[1]
x_loc = 20
y_loc = 20
x_loc = int(x_loc)
y_loc = int(y_loc)
imagem1.convert("RGB")
destino.convert("RGB")
for y in range(0, height):
for x in range(0, width):
xy = (x, y)
red, green, blue = destino.getpixel(xy)
x += x_loc
y += y_loc
destino.putpixel((x, y), (red, green, blue))
return destino.save("translate.png")
:
C:\Python27\python.exe C:/Users/Mikhail/PycharmProjects/SistMult/histograma.py
Traceback (most recent call last):
File "C:/Users/Mikhail/PycharmProjects/SistMult/histograma.py", line 289, in <module>
translacao(imagem1)
File "C:/Users/Mikhail/PycharmProjects/SistMult/histograma.py", line 262, in translacao destino.putpixel((x, y), (red, green, blue))
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1269, in putpixel
return self.im.putpixel(xy, value)
IndexError: image index out of range
프로세스가 종료 코드 완료 한
좋은 지적이지만 오류 메시지의 출처는 아닙니다. –
문제는 x와 y가 변환되고 번역이 이미지 바깥에 떨어진다는 것입니다. – carlosdc