IOS OpenGL ES GPUImage image xyderivativeedge detection GPUImageXYDerivativeFilter

catalogue

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES Basics

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES transition

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES special effects

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES functions

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES GPUImage use

Zero foundation OpenGL (ES) learning route recommendation: OpenGL (ES) learning directory >> OpenGL ES GLSL programming

1, Introduction

GPUImage There are 125 filters in total, which are divided into four categories

1. Color adjustments: 31 filters, color processing related
2. Image processing: 40 filters, image processing related
3. Blending modes: 29 filters, mixed mode correlation
4. Visual effects: 25 filters, visual effects related

GPUImageXYDerivativeFilter It is related to the visual effect of GPUImage images and is used for XYDerivative edge detection of images. The source code of shader is as follows:

/******************************************************************************************/
//@Author: apes say programming
//@Blog (personal blog address): www.codersrc.com
//@File:IOS – OpenGL ES GPUImage GPUImageXYDerivativeFilter
//@Time:2022/07/02 06:30
//@Motto: no small steps, no small streams, no rivers and seas. The brilliance of program life needs to be accumulated unremittingly!
/******************************************************************************************/

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageGradientFragmentShaderString = SHADER_STRING
(
 precision highp float;

 varying vec2 textureCoordinate;
 varying vec2 leftTextureCoordinate;
 varying vec2 rightTextureCoordinate;

 varying vec2 topTextureCoordinate;
 varying vec2 topLeftTextureCoordinate;
 varying vec2 topRightTextureCoordinate;

 varying vec2 bottomTextureCoordinate;
 varying vec2 bottomLeftTextureCoordinate;
 varying vec2 bottomRightTextureCoordinate;

 uniform sampler2D inputImageTexture;

 uniform float edgeStrength;

 void main()
 {
     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;
     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;
     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;
     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;
     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;
     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;
     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;
     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;

     float verticalDerivative = -topLeftIntensity - topIntensity - topRightIntensity + bottomLeftIntensity + bottomIntensity + bottomRightIntensity;
     float horizontalDerivative = -bottomLeftIntensity - leftIntensity - topLeftIntensity + bottomRightIntensity + rightIntensity + topRightIntensity;
     verticalDerivative = verticalDerivative * edgeStrength;
     horizontalDerivative = horizontalDerivative * edgeStrength;

     // Scaling the X * Y operation so that negative numbers are not clipped in the 0..1 range. This will be expanded in the corner detection filter
     gl_FragColor = vec4(horizontalDerivative * horizontalDerivative, verticalDerivative * verticalDerivative, ((verticalDerivative * horizontalDerivative) + 1.0) / 2.0, 1.0);
 }
);
#else
NSString *const kGPUImageGradientFragmentShaderString = SHADER_STRING
(
 varying vec2 textureCoordinate;
 varying vec2 leftTextureCoordinate;
 varying vec2 rightTextureCoordinate;

 varying vec2 topTextureCoordinate;
 varying vec2 topLeftTextureCoordinate;
 varying vec2 topRightTextureCoordinate;

 varying vec2 bottomTextureCoordinate;
 varying vec2 bottomLeftTextureCoordinate;
 varying vec2 bottomRightTextureCoordinate;

 uniform sampler2D inputImageTexture;

 uniform float edgeStrength;

 void main()
 {
     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;
     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;
     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;
     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;
     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;
     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;
     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;
     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;

     float verticalDerivative = -topLeftIntensity - topIntensity - topRightIntensity + bottomLeftIntensity + bottomIntensity + bottomRightIntensity;
     float horizontalDerivative = -bottomLeftIntensity - leftIntensity - topLeftIntensity + bottomRightIntensity + rightIntensity + topRightIntensity;
     verticalDerivative = verticalDerivative * edgeStrength;
     horizontalDerivative = horizontalDerivative * edgeStrength;

     // Scaling the X * Y operation so that negative numbers are not clipped in the 0..1 range. This will be expanded in the corner detection filter
     gl_FragColor = vec4(horizontalDerivative * horizontalDerivative, verticalDerivative * verticalDerivative, ((verticalDerivative * horizontalDerivative) + 1.0) / 2.0, 1.0);
 }
);
#endif

2, Effect demonstration

use GPUImageXYDerivativeFilter **, * * the original figure is as follows:

use GPUImageXYDerivativeFilter The effect is as follows:

3, Source code download

OpenGL ES Demo download address: IOS OpenGL ES GPUImage image xyderivativeedge detection GPUImageXYDerivativeFilter

4, Guess you like it

  1. IOS OPenGL ES set image brightness GPUImageBrightnessFilter
  2. IOS OPenGL ES adjust image exposure GPUImageExposureFilter
  3. IOS OpenGL ES adjust image contrast gpuimagecontractfilter
  4. IOS OPenGL ES adjust image saturation GPUImageSaturationFilter
  5. IOS OPenGL ES adjust image gamma line GPUImageGammaFilter
  6. IOS OpenGL ES adjust image anti color GPUImageColorInvertFilter
  7. IOS OpenGL ES adjust image brown GPUImageSepiaFilter
  8. IOS OpenGL ES adjust image gray GPUImageGrayscaleFilter
  9. IOS OpenGL ES adjust image RGB channel GPUImageRGBFilter
  10. IOS OpenGL ES adjust image opacity GPUImageOpacityFilter
  11. IOS OpenGL ES adjust image shadow GPUImageHighlightShadowFilter
  12. IOS OpenGL ES adjust image color replace GPUImageFalseColorFilter
  13. GPUImage - color histogram GPUImageHistogramFilter
  14. GPUImage – color histogram GPUImageHistogramGenerator
  15. GPUImage – pixel average color value GPUImageAverageColor
  16. GPUImage - brightness average GPUImageLuminosity
  17. IOS OpenGL ES adjust image chroma GPUImageHueFilter
  18. IOS OpenGL ES specifies color matting GPUImageChromaKeyFilter
  19. IOS OpenGL ES adjust image white balance / color temperature GPUImageWhiteBalanceFilter
  20. IOS OpenGL ES setting image lookup filter GPUImageLookupFilter
  21. IOS OpenGL ES setting image filter GPUImageAmatorkaFilter
  22. IOS OpenGL ES set image filter GPUImageSoftEleganceFilter
  23. IOS OpenGL ES set image sharpening GPUImageSharpenFilter
  24. IOS OpenGL ES drawing cross GPUImageCrosshairGenerator
  25. IOS OpenGL ES drawing lines GPUImageLineGenerator
  26. IOS OpenGL ES set image black and white dots GPUImageLocalBinaryPatternFilter
  27. IOS OpenGL ES set image cartoon effect (black thick line stroke) GPUImageToonFilter
  28. IOS OpenGL ES sangyuan filter / gouache blur effect GPUImageKuwaharaFilter
  29. IOS OpenGL ES black and white mosaic effect gpuimagemosaic filter
  30. IOS OpenGL ES pixelated mosaic effect GPUImagePixellateFilter
  31. IOS OpenGL ES concentric circle pixelated mosaic effect GPUImagePolarPixel
  32. IOS OpenGL ES black and white mesh effect gpuimagecrosshatchefilter
  33. IOS OpenGL ES color loss / Blur effect GPUImageColorPackingFilter
  34. IOS OpenGL ES image vignettefilter GPUImageVignetteFilter
  35. IOS OpenGL ES image vortex GPUImageSwirlFilter
  36. IOS OpenGL ES image fisheye diffusion effect gpuimagebulgedisportionfilter
  37. IOS OpenGL ES image fisheye movement effect gpuimagebulgedisportionfilter
  38. IOS OpenGL ES image concave mirror moving effect gpuimagepinchdistorionfilter
  39. IOS OpenGL ES image concave mirror magnification effect gpuimagepinchdistorionfilter
  40. IOS OpenGL ES image hatching mirror effect GPUImageStretchDistortionFilter
  41. IOS OpenGL ES image crystal ball effect GPUImageGlassSphereFilter
  42. IOS OpenGL ES image spherical refraction GPUImageSphereRefractionFilter
  43. IOS OpenGL ES image hue separation noise effect GPUImagePosterizeFilter
  44. IOS OpenGL ES image CGA color filter GPUImageCGAColorspaceFilter
  45. IOS OpenGL ES image Berlin noise / Lace noise GPUImagePerlinNoiseFilter
  46. IOS OpenGL ES image highlight edge gpuimage3x3colutionfilter
  47. IOS OpenGL ES image relief 3d effect GPUImageEmbossFilter
  48. IOS OpenGL ES image mosaic dot GPUImagePolkaDotFilter
  49. IOS OpenGL ES image erosion edge black and white blur GPUImageErosionFilter
  50. IOS OpenGL ES image erosion edge color blur GPUImageRGBErosionFilter
  51. IOS OpenGL ES image extended edge black and white blur GPUImageDilationFilter
  52. IOS OpenGL ES image extended edge color blur GPUImageRGBDilationFilter
  53. IOS OpenGL ES GPUImage black and white tone blur GPUImageOpeningFilter
  54. IOS OpenGL ES GPUImage color blur GPUImageRGBOpeningFilter
  55. IOS OpenGL ES GPUImage image black and white tone blur / dark color brighten GPUImageClosingFilter
  56. IOS OpenGL ES GPUImage image color blur / dark brighten GPUImageRGBClosingFilter
  57. IOS OpenGL ES GPUImage image Lanczos resampling blur effect GPUImageLanczosResamplingFilter
  58. IOS OpenGL ES GPUImage image shows the pixels with the highest brightness, and the others are black gpuimagenonmeximumsuppressionfilter
  59. IOS OpenGL ES GPUImage image shows the pixels with the highest brightness, and the others are black gpuimagethresholdnonmeximumsuppressionfilter
  60. IOS OpenGL ES GPUImage image Sobel edge detection, similar to comic anti color GPUImageSobelEdgeDetectionFilter
  61. IOS OpenGL ES GPUImage GPUImageWeakPixelInclusionFilter
  62. IOS OpenGL ES GPUImage GPUImageDirectionalNonMaximumSuppressionFilter
  63. IOS OpenGL ES GPUImage image threshold edge detection GPUImageThresholdEdgeDetectionFilter
  64. IOS OpenGL ES GPUImage image Prewitt edge detection GPUImagePrewittEdgeDetectionFilter
  65. IOS OpenGL ES GPUImage image xyderivativeedge detection GPUImageXYDerivativeFilter

This article is written by blog - Ape programming Ape programming release!

Tags: C OpenGL gpuimage

Posted by avo on Mon, 01 Aug 2022 22:40:55 +0530