ComfyUI Node
SOBEL (JOV_GL)
Finds the edges of an image
SOBEL (JOV_GL)
- image
- RGBA
- RGB
- MASK
◄FRAGMENT// name: SOBEL
// desc: Finds the edges of an image
// category: FILTER
uniform sampler2D image; // | RGB(A) image
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
float x = 1.0 / iResolution.x;
float y = 1.0 / iResolution.y;
vec2 uv = fragCoord / iResolution.xy;
vec4 horizEdge = vec4( 0.0 );
horizEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0;
horizEdge -= texture( image, vec2( uv.x - x, uv.y ) ) * 2.0;
horizEdge -= texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0;
horizEdge += texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0;
horizEdge += texture( image, vec2( uv.x + x, uv.y ) ) * 2.0;
horizEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0;
vec4 vertEdge = vec4( 0.0 );
vertEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0;
vertEdge -= texture( image, vec2( uv.x , uv.y - y ) ) * 2.0;
vertEdge -= texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0;
vertEdge += texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0;
vertEdge += texture( image, vec2( uv.x , uv.y + y ) ) * 2.0;
vertEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0;
vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb));
fragColor = vec4( edge, texture( image, uv ).a );
}►
CategoryJOV_GL 🌈/FILTER
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| imageopt | IMAGE | RGB(A) image | |
| FRAGMENTopt | STRING | // name: SOBEL // desc: Finds the edges of an image // category: FILTER uniform sampler2D image; // | RGB(A) image void mainImage( out vec4 fragColor, in vec2 fragCoord ) { float x = 1.0 / iResolution.x; float y = 1.0 / iResolution.y; vec2 uv = fragCoord / iResolution.xy; vec4 horizEdge = vec4( 0.0 ); horizEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y ) ) * 2.0; horizEdge -= texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; horizEdge += texture( image, vec2( uv.x + x, uv.y ) ) * 2.0; horizEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec4 vertEdge = vec4( 0.0 ); vertEdge -= texture( image, vec2( uv.x - x, uv.y - y ) ) * 1.0; vertEdge -= texture( image, vec2( uv.x , uv.y - y ) ) * 2.0; vertEdge -= texture( image, vec2( uv.x + x, uv.y - y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x - x, uv.y + y ) ) * 1.0; vertEdge += texture( image, vec2( uv.x , uv.y + y ) ) * 2.0; vertEdge += texture( image, vec2( uv.x + x, uv.y + y ) ) * 1.0; vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); fragColor = vec4( edge, texture( image, uv ).a ); } | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| RGBA | IMAGE | Full channel [RGBA] image. If there is an alpha, the image will be masked out with it when using this output. |
| RGB | IMAGE | Three channel [RGB] image. There will be no alpha. |
| MASK | MASK | Single channel mask output. |