diff options
Diffstat (limited to 'convolve.html')
| -rw-r--r-- | convolve.html | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/convolve.html b/convolve.html new file mode 100644 index 0000000..24e3590 --- /dev/null +++ b/convolve.html @@ -0,0 +1,67 @@ +<style> +canvas { display: inline-block; } +</style> +<body></body> +<script src="convolve.js"></script> +<script src="smartblur.js"></script> +<script src="fetch.js"></script> +<script> + +var url = 'img/oranges.jpg' +var smart_blur = new SmartBlurFilter () + +var identityArray = [ + 1, +] +var brightArray = [ + 2, +] +var dimArray = [ + 0.5, +] +var oddArray = [ + -1, -1, -1, + -1, 8.5, -1, + -1, -1, -1, +] +var blurArray = [ + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1 +] + +var edgeArray = [ + 0,-1,0, + -1,6,-1, + 0,-1,0, +] + +var kernels = [ +// new Kernel(1, 1, identityArray), + new Kernel(1, 1, brightArray), + new Kernel(1, 1, dimArray), +// new Kernel(3, 3, oddArray), +// new Kernel(3, 3, edgeArray).normalize(), + new Kernel(9, 9, blurArray).normalize(), +] +var convolvers = kernels.map(function(kernel){ + return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null) +}).concat(kernels.map(function(kernel){ + return new ConvolveOp(kernel, ConvolveOp.EDGE_ZERO_FILL, null) +})) + +fromImage(url, function(canvas){ + document.body.appendChild(canvas) + convolvers.forEach(function(convolver){ + var convolved = convolver.convolveCanvas(canvas) + document.body.appendChild(convolved) + }) +}) + +</script> |
