Last change
on this file since 12397 was
12115,
checked in by wiesep, 6 years ago
|
Changed folder structure, deletet some unused files and cleaned up code
|
File size:
832 bytes
|
Line | |
---|
1 | sampler2D Image : register(s0); |
---|
2 | |
---|
3 | // The Laplace filter approximates the second order derivate, |
---|
4 | // that is, the rate of change of slope in the image. It can be |
---|
5 | // used for edge detection. The Laplace filter gives negative |
---|
6 | // response on the higher side of the edge and positive response |
---|
7 | // on the lower side. |
---|
8 | |
---|
9 | // This is the filter kernel: |
---|
10 | // 0 1 0 |
---|
11 | // 1 -4 1 |
---|
12 | // 0 1 0 |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | float4 Laplace_ps ( float4 pos : POSITION, |
---|
17 | float2 texCoord: TEXCOORD0, |
---|
18 | uniform float scale, |
---|
19 | uniform float pixelSize) : COLOR |
---|
20 | { |
---|
21 | |
---|
22 | float2 samples[4] = { |
---|
23 | 0, -1, |
---|
24 | -1, 0, |
---|
25 | 1, 0, |
---|
26 | 0, 1 |
---|
27 | }; |
---|
28 | float4 laplace = -4 * tex2D(Image, texCoord); |
---|
29 | |
---|
30 | // Sample the neighbor pixels |
---|
31 | for (int i = 0; i < 4; i++){ |
---|
32 | laplace += tex2D(Image, texCoord + pixelSize * samples[i]); |
---|
33 | } |
---|
34 | |
---|
35 | return (0.5 + scale * laplace); |
---|
36 | } |
---|
37 | |
---|
Note: See
TracBrowser
for help on using the repository browser.