[Bf-committers] pixel get & image processing

Campbell Barton ideasman42 at gmail.com
Tue Apr 27 17:52:40 CEST 2010


This is an area of the api Id like to look into but think that
getpixel functions via rna are too slow.
I did some simple tests and the overhead for an function call was
roughly 8X, compared to the blender 2.4x python api.

While this is generally bad practice to give such low level access to
python, Id favor memory buffer access to the image, or not at all,
since functions per pixels are incredible slow.

On Tue, Apr 27, 2010 at 5:46 PM, Sebastian Korczak
<admin at myinventions.pl> wrote:
> I'm sorry for Thunderbird formating error, that's the correct text:
>
> I'm working on 2.5 implementation of old image.getPixelI(x,y) for returning the color
> of the (x,y) pixel in the format [r,g,b,a].
> getPixelI(x,y) is an instance method in image class (2.49b).
>
> Maybe I'm wrong, but Blender 2.5 haven't methods like this we can access from python code.
>
>
> So, first I made get pixel property in bpy.types.image:
>     bpy.data.images['image_name'].pixels
>
> - property have access to ImBbuf but can't take any arguments like pixels(x,y).
> -  image properties are in \source\blender\makesrna\intern\rna_image.c
>
>
> Then I made getpixel operator in bpy.ops.image:
>        bpy.ops.image.pixel(image='im', x=1, y=1)
>
> - it takes arguments but there are problems:
>         - how to access image with it's name only (context.space is text_editor) or
>                with it's struct from bpy.data.images['image_name'] or
>                with it's pointer from bpy.data.images['image_name'].as_pointer()
>        - how to return rgba values
> - image operators are in source\blender\editors\space_image\image_ops.c
>
> Any ideas?
>
> What do you think about start Blender Image Processing module with operators like this:
> bip.getPixel(image=im, x=1, y=1)
> bip.filter(image=im, filter='greyscale')
> bip.threshold(image=im, R=128, G=128, B=128, A=255)
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
- Campbell


More information about the Bf-committers mailing list