[英]how to generate different color images according to one image in java or python?
I want to generate some images in different color according to one image.But I couldn't find some resources about this.Could you recommand some useful reference material about how to implement by using java or python. 我想根据一张图像生成一些不同颜色的图像,但是我找不到与此有关的资源,能否请您推荐一些有用的参考资料,介绍如何使用java或python实现。
for example,the images below is generated from one image. 例如,以下图像是从一张图像生成的。
In Python, you can take the help of the Image module to do this stuff. 在Python中,您可以借助Image模块来完成此工作。
For example - 例如 -
import Image
picture = Image.open("/path/to/my/picture.jpg")
r,g,b = picture.getpixel( (0,0) )
print("Red: {0}, Green: {1}, Blue: {2}".format(r,g,b))
This above code will give you information about the pixel at (0,0) 上面的代码将为您提供有关(0,0)处像素的信息
import Image
picture = Image.open("/path/to/my/picture.jpg")
# Get the size of the image
width, height = picture.size()
# Process every pixel
for x in width:
for y in height:
# get pixel color
current_color = picture.getpixel( (x,y) )
# your main logic here to choose new color
# put the new color on the pixel
picture.putpixel( (x,y), new_color)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.