Skip to main content

PYTHON PROCESSING / Working with Image

IMAGE being drawn on top of each other on every loop. Each image is drawn on the position of mouse X and Y. Can you guess what image is this?

Continuing with my Python Processing study. I wanted to touch on IMAGE object real soon because it is one of the most fun topic we can do pretty quickly and easily.

While doing this, I am also looking at the provided example on IMAGE topic and also this YouTube video tutorial by John Park on Processing 3 (Java): https://youtu.be/ddtdPO3m1hw



What I am showing here is pretty basic however important for beginners and I am familiarizing myself with Python language for Processing. Instead of Java.

The whole code looks like below, with some parts commented for you to try yourself:

Few important notes:

  • With Python, we do not seem have to explicitly specify the TYPE of object instance we are creating, in this case the IMAGE type. We simply load the image from path. Python guess the object type.
  • We probably need to definte the image variable as GLOBAL
  • imageMode(CORNER) or imageMode(CENTER) are useful to set the placement of image
  • noLoop() and background() are kind of related. When we allow LOOP and draw() to run everytime and with no background() we will get the image being drawn over and over again each processing run, so we get overlapping result
I really feel that Python language really makes Processing experience a lot friendlier.

A slight modification to the script above and we can get this image below.

Image YOSHI that I borrowed from the Internet. It's PNG so it can have transparency.



Not sure how the whole Processing works together with Python modules or Java modules, but in the basic level, loading image, displaying image and assigning MOUSE POSITION to draw the image is a lot simpler!

There are many other METHODS of IMAGE object type in Processing you can use to modify the image, you can check for image related examples and also the documentations.

I guess the rest is up to you what you wanted to do with image, but this is only touching the very basic of:
- Creating a variable for image type of object
- Loading Image
- Displaying Image
- Drawing Image on specific position
- Drawing Image on mouse position

Enjoy!

Comments

Popular posts from this blog

PYTHON / OpenCV, Recreate Uncanny Manga - Anime Style

Can you tell what it is? Computer Vision. Yesterday, I spend almost whole day exploring this opencv module using Python. What I discovered was revealing. Even at the very basic level, I could produce some interesting Image and Video manipulation using all the code collected from documentation and many, many blog tutorials. If you are a total noob like me, I am still getting used to knowing that the CV in OpenCV means Computer Vision! Actuallly, I recalled that I did try to get into OpenCV few years back ago, when I knew no Python and when Python opencv module was probably still early. It was all C++ code and it was a little bit too hard for me. I read a couple of books about opencv at the library, I did not understand a single thing. That was back then. Today, for strange reason, with a bit of knowledge of Python, I can go a little further. EDGE DETECT IN OPENCV Me holding you know what. What leads me this far is my curiosity on how we can replicate Wolfram Langu...

JUPYTER / More Interesting Modules

Turtle slowly walks in spiral in search for Zen of programming. Over the weekend, I am again searching and exploring Jupyter Notebook in a heuristic fashion. I indeed found some interesting modules along the way that worth nothing, and as well discovering a few more *hickups*. Basically, I have a need to find enough "visual" modules, probably under 10 modules, that give me starting tools so that I could create some interesting Image Output, in the way that Wolfram Language can. Wolfram Lab Cloud indeed is powerful visually. I don't know how to explain, but being able to query Planets images (or all kind of stuff), and then seeing the list as image picture of some sort, then filtering the list or further scrambling the images... are brilliant. So, I do have come to some realization that a lot of codes are to be required and studied in order to be able to make some of the "cool stuffs" that Wolfram can do much easier. Yet, still, there is a good feel...

WOLFRAM / Digging BIG Data for Visualization

My personal interest in Wolfram from the start is because of Wolfram's BIG KNOWLEDGE BASE. And also the way Wolfram could "filter" and "re-present" those data back to users in an interactive and rich kind of way. I supposed it would be a really good personal case study and research for DATA VISUALIZATION . If you are interested in Data Science, you should also check thing like R Programming. Or maybe look up some ways Python can process data. SomethingData[] Now, we know that Wolfram knows A LOT. However to access those knowledge, we need some kind of understanding about the way Wolfram store the data. We can tell Wolfram to QUERY data using Wolfram Language SYMBOL, which I believe it will give you ENTITY, and further more the PROPERTIES of ENTITY. For example: 1) Supposed we want to know more about our PLANET: Earth . Wolfram recognize this "Earth" as a String. What if we want to actually find out more about ENTITY called EARTH? 2) We cou...