Horizontal Blur/Avaraging pixel values

For reasons, I need to average each row of pixels in a frame.
I can do this with OpenCV, but that annoyingly slow, even on a fast computer.

This is my current approach using OpenCV:
image

Is there a way to get proper horizontal blur/averaging of the pixels, line by line in FUSE or in vanilla stride?

Sune

What is your resolution and fps? Maybe there is a smart way using hardware interpolation for that one. how about stretching your texture from 128x128 to 1x128 using linear interpolation, and then reading back these values?

scaling like that will only give me the middle pixel value.
I tried consecutive iterations of horizontal blur, but somehow it also affected the vertical dimension.
also I need resolutions up to, and maybe beyond 4K

using one pipet for each pixel is particularly slow. get a whole line at once and average that. the Stride pipet has an input for a list of pixel coordinates.

How would that speed things up? I still need to read all lines.

The thing is, this is video, so nut just one frame, in this case it is 24 frames per second.

Could do with a compute graph like this


Example Average Pixels.vl (38.2 KB)

2 Likes

@texone That is amazing! thanks

Out goes OpenCV

Now the question is how I get the texture back or, even better, readback the new vertical line of pixels to a spread of Vector4 or RGBA

with Pipet, have a look at the help patch.

@tonfilm Pipet will not take the resulting ShaderNode.
So I either need to read that back directly or change it into a texture to readback with pipet

you would read back the ComputeTexture2D in the patch.

Exactly readback texture to a mutablearray
image

Thanks guys, this is amazing :)

Depending on how you read it back, either the main loop gets blocked or you receive the result from a few frames earlier. Unfortunately, there are some obstacles in the way when transferring data from the GPU to the CPU.

I am quite used to that, I use it regularly, the latency is fine

1 Like

On that note, will the VideoPlayer run in incremental time, is the mainloop is set to incremental?

unlikely, but @Elias knows fore sure.