I'm not sure what is the correct and fastest way to do this. Locking a texture/surface and manipulating the raw pixel data? How is
this done in modern graphics programming?
If this is something to recompute each frame, if the only input you need is the pixels position, and if you only need to output this directly to the screen, I suppose the modern and fastest way to to this is to simply use a pixel shader on the GPU. Render a full-screen quad with your favorite engine, with a pixel shader that computes a color from the pixel's position. This is similar to doing a full-screen post-process.
If you only need to recompute this one in a while, or if you need to output to something else than the screen, you could render to a texture for later use.
If you need more inputs than simply a pixel's position, you'll have to find a way to pass this info to your pixel shader. You can use uniforms, textures etc. for this purpose.
There are cases where you could use the CPU for the sake of simplicity. It will be easier to handle inputs/outputs, and you could save some texture copying time in some cases, but you'll need to workaround the fact that CPUs aren't really made to work on arrays of pixels. To avoid hiccups, you'll have to do it during a loading time, on a different thread, or even offline.