Texture processing on the GPU

I have a texture, I want to process every pixel and write out a new texture. Right now, I am doing this in a Python script, and have optimized the hell out of it, but it is just too slow. Doing 4,194,304 (2048x2048) operations, converting RGB to HSL, is going to take a while. I wanted to harness the power of the GPU to process in parallel, it would be almost instantaneous. Is there any somewhat easy way to do this, without having to do a bunch of custom stuff in OGL or DX?

There are two routes, making an app that that renders the textures using the GPU or using a GPGPU language like CUDA.

There are at least two Python Cuda wrappers, but I think maybe cuda is an overkill - it looks complicated to me :slight_smile:

There are some python based image processing that uses GPU that might be worth looking at.

PYFX
http://www.cs.lth.se/home/Calle_Lejdfors/pyip/

PYGPU
http://www.cs.lth.se/home/Calle_Lejdfors/pygpu/#Examples

PyCUDA
http://mathema.tician.de/software/pycuda

Not what you want but of interest,Nvidia had a photoshop filter that you could use .fx to process your image - buggy when I tried it. Also there is a similar Gimp plugin.

What would be really handy is a simple command line tool that you can do processing using a provided .fx HLSL file!

One thing to remember with using the GPU directly, you may get different results depending on which card you use. So its worth checking this out if you run it on a range of GPUs. Mainly its between different Brands of GPU, but sometimes different series also.

I think GPGPU stuff for this is a bit overkill, after all its not a real-time task. Regular C/C++ SSE maybe some OpenMP will do just fine.

As a start you could try regualr C code in python?
http://www.cs.tut.fi/~ask/cinpy/

although from the looks it might be same as pycuda.

I ended up writing a photoshop javascript… definitely not as nice, but the pain of doing it was less than the pain of getting this stuff set up (uses an existing PS filter plugin and does some other stuff). This is certainly interesting stuff, though.

http://developer.download.nvidia.com/SDK/9.5/Samples/samples.html#GPUFilter

I just found that filter for photoshop, when I tried it - it was flakey!
It uses .cg and opengl