![]() ![]() There is also a module called ImageOps that exposes image processing functions such as colorize(), flip(), grayscale(), invert(), mirror(), solarize(), or posterize(). Predefined filters are: BLUR, CONTOUR, DETAIL, EDGE_ENHANCE, EDGE_ENHANCE_MORE, EMBOSS, FIND_EDGES, SMOOTH, SMOOTH_MORE, and SHARPEN. You can easily apply common image filters with PIL: blur, emboss, sharpen, etc. With Image.getdata(), the last lines of the previous script would be: HYP_Texture.SetValueTex2DByteRgb(texId, offset, rgb, rgb, rgb) TexId = HYP_Texture.Create(TEXTURE_2D, RGB_BYTE, imageW, imageH, 0) #Pil getdata codeHere is a code snippet that loads an image with PIL, creates a texture object with GeeXLab Python API and fills the texture with image pixels. You need the Python function list() to create the pixmap list of RGB tuples. Just give a tuple with the X and Y coordinates and getpixel() returns a 3-tuple RGB for a RGB image or a single value for a luminance image. getpixel() returns the value of a single pixel. There are two functions that make it possible to read the pixmap (or pixel data): Image.getpixel() and Image.getdata(). jpg extension to your image filename… Same thing for the other formats.įormats supported in reading AND writing: *. You want to save to JPEG format? Just add the. On my system, Irfanview is called to display the image: Under Windows, the Image.show() function saves the image to a temporary file and calls the default image viewer utility. Img_filename = "%s/flower.jpg" % scriptDir ![]() If you need it, PIL version can be found in the Image.VERSION variable. Here is a small INIT script that uses PIL to load an image and display it. Of course you need a valid Python 2.6.6 installation before. #Pil getdata windowsUnder Windows (XP, Vista or Seven) the installation of PIL is rather simple: just launch the PIL Windows installer and you’re ok. I’ll use PIL 1.1.7 for Python 2.6 in this article. The current version of PIL is PIL 1.1.7 and is available for Python 2.3 up to Python 2.7. PIL or Python Imaging Library is a package that exposes many functions to manipulate images from a Python script. That said, let’s talk about the first Python lib: PIL. That way, you will be able to quickly re-use all code snippets in your own python projects. #Pil getdata seriesThis quick description of GeeXLab scripting is important for this series of tutorials about Python libraries because I’m going to focuse on the functionalities offered by those libraries and I’ll try to limit the use of GeeXLab functions to the bare minimum. GeeXLab Host-API functions description is available HERE. That’s why, most the Python packages available will work with GeeXLab.Īnd to interact with GeeXLab scene data (textures, GLSL shaders, meshes, etc.) there is the Host-API which is simply GeeXLab API for Lua and Python. There is no restriction: GeeXLab can be seen as a virtual machine for Lua and Python. In a script you can code what you want with both languages. These scripts can be programmed either in Lua or in Python. Roughly speaking, a demo is made up of an initialization script (INIT, executed once) and a per frame script (FRAME, executed every frame). GeeXLab has a very simple way of working. The purpose of this series is to do an overview of the Python libraries that may be useful for GeeXLab demos AND that work with GeeXLab. This is the first tutorial about Python and GeeXLab. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |