bledner scripting noob here

hi people,

just hopped into python&blender today :slight_smile:

my first two question are:

  1. where to get good start-off tutorials about python & blender?

  2. how can i achieve this: i have a black&white, 1-bit image. i want to read each its pixel and store its value to a list (black or white; 0 or 1).

thanks, hope u understood what i need :slight_smile:

I can only help you on the 1st question:
Here you can find what you’ll need as a tutorial.
This is the API doc for Blender.
And the forum is a good place to learn. Try to read and understand the scripts found within Blender too…
Good luck !

thakns :slight_smile:

to that 2nd problem: i’ll try to explain it bit more.

i want to achieve this: blender loads an image. script creates a list of doubles containing the current coordinates (eg. if an image size is 30x50, the list would be (0,0),(0,1),(0,2)…). then the script iterates through each of the coordinates, writing down the color value, whether it’s black or white ((0,0)=1, (0,1)=0)…

what modules should i use to get the image-unpacking?

thx :slight_smile:

Sounds like you are just trying to create a mask from an image?

What if the image has color?

if the image has color, i won’t use it :slight_smile:

now i’m just trying to get this done, and AFTER that i will bother with colors.

This should help you:

The class Image has the methods “getPixelF(x, y)” and “getPixelI(x, y)” which give you the information you want. (Don’t tangle up Blender Units and Pixels g)




thanks, that’s what i wanted: those 2 functions :slight_smile: :slight_smile:

Also, I found that doing the python walk through that comes with python was very helpful, if you don’t know how to program in python already. It doesn’t take too log to read through and do a few examples. Good investment of time.

Something like this…

import Blender
from Blender import Image
image = Image.Load("/path/to/my/image.png")    # load an image file
myPixelDepth = image.getDepth()
#Check for two color image.
if myPixelDepth < 2:
    aryImageMetrics = image.getSize()
    myWidth = aryImageSize[0]
    myHeight = aryImageSize[1]
    for y in range(myHeight):
        for x in range(myWidth:
            myRGBA = image.getPixelI(x, y)


i ended up with something like this:

print obrazok.getFilename()
for a in range(width):
    for b in range(height):
        #print colInfo #for debugging, uncomment this line
        if colInfo[0]==colInfo[1]==colInfo[2]<float(0.5):


i am just wondering how to do this modeller with the third dimension