Different blurFilter.texelSpacingMultiplier for different regions in image GPUImageCannyEdgeDetection filter

StackOverflow https://stackoverflow.com/questions/23512565

  •  16-07-2023
  •  | 
  •  

Question

I want to set different blurFilter.texelSpacingMultiplier for different regions in image in GPUImageCannyEdgeDetection filter is there a way to do that.

Was it helpful?

Solution

The texelSpacingMultiplier is defined as a uniform in the fragment shaders used for this operation. That will remain constant across the image.

If you wished to have this vary in parts of the image, you will need to create a custom version of this operation and its sub-filters that takes in a varying value for this per-pixel.

Probably the easiest way to do this would be to have your per-pixel values for the multiplier be encoded into a texture that would be input as a secondary image. This texture could be read from within the fragment shaders and the decoded value from the RGBA input converted into a floating point value to set this multiplier per-pixel. That would allow you to create a starting image (drawn or otherwise) that would be used as a mask to define how this is applied.

It will take a little effort to do this, since you will need to rewrite several of the sub-filters used to construct the Canny edge detection implementation here, but the process itself is straightforward.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top