Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>Javascript Edge Detection</h2>
  <p>
    Javascript and HTML5 Canvas is used to detect irregularites in image data. The image on the left is copied onto the canvas on the right, and overlayed with plotted points that are detected "Edges" in the picture.<br>
    You may notice that the carpet brings up some "edges", these can be avoided by improving the edge-detection algorithm, making it check more pixels than just the immediate ones.<br><br>
    Check out the source code for an in-depth look at what's going on. The default threshold is 30.
  </p>
<div class="wrapper">
  <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQTEhUUEhQWFhQXFxUXFxgYGBQXGBcXFRQWGBcYFxcYHCggGBwlHBUVITEhJykrLi4uFx8zODMsNygtLiwBCgoKBQUFDgUFDisZExkrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrK//AABEIAKgBLAMBIgACEQEDEQH/xAAcAAAABwEBAAAAAAAAAAAAAAAAAQIDBAUGBwj/xAA+EAABAwIEAwYEBAYBAwUBAAABAAIRAyEEEjFBBVFhBhMicYGRBzKhsULB0fAUI1JicoLhFReiM1ODkvEI/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAA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aYFps3kAZgQk42W+AZMrpbpLSPLSf13QY8u5pQP71VpjOBEAGmZsCQbXPKfI2VVVY5hLXCCgGblYi4O4OxB2XoH4U9r6OKZ3T3NZiPxMJjOf66fMHdou3ygnz2UpruW1x6boPaFOnC4B/8A0BxWnVxlGlTIc6hTcKhEWdUcDkPUBoJ/yWIp9sMcGZBjMTliI76ppyBmQqKrUm/O58zv1QNvKbKNxRILXgLZz/6/mj4zWAGQa/kqyjXc0y0wUh5JMm5QJSwEQCUgCCCNAEEEYQAI0UIIOjU8O4mXABo+WSQCDcz/APU2010QNEvYD4WXEw2CZdew32v+SCCCZTqPEhoIvJNvEd4i0C2vJMV3udMmIAIsOQ57ZT/zKCCC0whORkeEu1OvuIuY2H9IteVCxJA0iJIM+GOoBuTbX73RIIGSzKw+I7uIN9dfr++aWkEEtc+XeIB0ZYMWBGoM6G+nKCEEEilSDWgulx8UeZnXaZE+xUJ7jWfE/KJywQMm0Qb3PrdBBAmq4kuDiSLzANoBFibe86aXspzA0tdGQCAYaQXRplvoSdL6lGggAxfhPhls/Ne+0ZgRPzbc9kdUZg3MIDbSdr6nptN0aCByvUnNLwRYbeEASTcTO8W2Nk3SbEuLhBnSIOYb9dLfqggggh+cwHXM6iwi4FtTe9k/gCaeoaD/AFZQTbUE67mEEECqeKmCWg75hl3tvdhmPfqixtMTmAmJ5SdCBNgen5okEA/h3vALTFpLdjeReSI6HpzTGLwYy/zYcdSQJtzjnoP03JBBW0+z4qGwcwEEtuDPKRcjbdVeL4TVpmCJ6hEgghvpncHSfQ7+SZhGggQ4IZUEEBtppQZqeX7hBBAQahCNBAMqGVBBAeVHkQQQLFIoixBBB//Z" alt="Dice" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcScO2IYH0FvmzbSKbQIn-mulUBxXSMX_1tRAvr_qmadxj5y-4ztMw" id="image"></div>
       <br>
  Threshold:<input type="input" id="threshold" value="30"><br><span class="help">(Hit enter or return after changing the value)</span>
              
            
!

CSS

              
                body{
  text-align: center;
  font-family: "Libre Baskerville", Arial;
  margin: 0 auto;
  width: 80%;
  background: #E9E9E9;
  background-color: rgb(106, 155, 181);
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAANA0lEQVR4Xu3czdENWxTGcR0Aox4JgAAIgAAEQAAEQAACIAACIAABEAABEIDRGRGA+95b9T+D361VpnuwVam3uk/vr+71rL0+nrWPd+/enS9evLj098+fP+dxHJd79+6dP378uHT9+vXr8+b/5efPn+fdu3cvnz9/Ph8/fnx58ODB+e3bt+v1r1+/zjt37lzbd93z9fP9+/fz/v37l5cvX55v3769PHny5Pz06dPl69ev58OHD6/Xzevmt/PmmUv99Vz9PXr06Pzy5cv1964bt3XU/mYN581a/jfvDx8+nM+ePbvUvnFr33yfP39+vn///jpP11H/3W/c+mlevc/e43Fr/1vqDRx9wSQhieyLvnnz5nz16tUliU6Capckdb8vHsKSpNo/ffr0/Pjx4+XmLZw3/6+S2P2eb/zmU389F6Kan8hJAhu369p3P8l03Nu3b5+/f/++aogQqYQ3r/42j95D47SOxnO+jbcRshQ+bt06khx1dxKY5CSJ6vruJwHq7H5PMvobQrpu/CRYxIlIkSZy69/nmn97T9dJshqh55Tonk+ynV/3a9fv7intNWmojZDVEKIEhwh1fPf7kunMJKjr+utv7ZLg+k3Hirx0tFZQe1XjiSCtttrXf+2S0JCTJDefJNrnQ36aQKuz8Scrtfb1795avxshqyEkiU+H9yWTyHS81kr3ldj60fqovTrcPUXJ1k5vvvWn/6Ek1n8SWLv+Nn/nrRUnAkJa/XadBui6/n1P7l2tcyNkNYT0pdSRIqcvn85Vx6eru6+dnyQlCUp246Vb0/E9517TvBuvPUU/QQ+/+et31K5xQ0ztk3Dnp1VmP71XPfv2ksZrHRshqyGkL9+XTdK0oqZYUe1D0KRrlbB0u7Gj5qHHLyJDSBLc+F2HhJ7THwkBIkZE1a73UbuQ4Z6rJpisRde5PfXFkNF0/lVZ/8WUkgCtJ7+k0dsQ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6aCbTiSQn3d8+Mt17EyIAxro2Q1RDiF9S+92QD2d994fqZ6itk6E3Rz3S3TEOtQWNoIWyy9834eVKEmbwps2dkwPGal4zPxjOWZrXxRshqCNG/SEfqSWt/97vWQzrSzJwRANni2vv1K/PQHLv5kRDdHmZ9itW0Zkz1w7T+9OT1y/rd9xjCu9+6PJ11I2Q1hKQr/euJaHq0xmKmDGASZKwpidEOt65Dtoo1kF5rzZlbbx2eadK4nt1iPsaT5kSYHIDptKQpQrIRshhC/gHtHrmQrELu6gAAAABJRU5ErkJggg==);
}
h2{
  font-size: 5em;
  font-family: "Lobster";
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}
p{
  width: 80%;
  margin: 0 auto;
  margin-top: 20px;
  margin-bottom: 20px;
  text-align: center;
  font-family: "Droid Sans";
}
.wrapper{
  padding: 5px;
  background: #FEFEFE;
  display: inline-block;
  box-shadow:0px 0px 4px rgba(0,0,0,0.2);
  border-radius: 3px;
  padding-bottom: 1px;
  margin-bottom: 20px;
}
.help{
  font-size: .6em;
}
              
            
!

JS

              
                function edgeDetector(){
  
  // Variables
  this.img = undefined;
  this.imgElement = undefined;
  this.ctx = undefined;
  this.canvasElement = undefined;
  this.rawCanvas = undefined;
  this.rawctx = undefined;
  this.ctxDimensions = {
    width: undefined,
    height:undefined
  };
  this.pixelData = undefined;
  this.threshold = 30;
  this.pointerColor = 'rgba(255,0,0,1)';
  
  
  this.init = function(){
    // Build the canvas
    var width = $(this.imgElement).width();
    var height = $(this.imgElement).height();
    $("<canvas id=\"rawData\" width=\""+width+"\" height=\""+height+"\"></canvas>").insertAfter(this.imgElement);
    $("<canvas id=\"layer\" width=\""+width+"\" height=\""+height+"\"></canvas>").insertAfter(this.imgElement);

    this.canvasElement = $("#layer")[0];
    this.rawCanvas = $("#rawData")[0];
    this.ctx = this.canvasElement.getContext('2d');
    this.rawctx = this.rawCanvas.getContext('2d');

    // Store the Canvas Size
    this.ctxDimensions.width = width;
    this.ctxDimensions.height = height;
  };
  
  this.findEdges = function(){
    this.copyImage();
    this.coreLoop();
  };
  
  this.copyImage = function(){
    this.rawctx.clearRect(0,0,this.ctxDimensions.width,this.ctxDimensions.height);
    this.ctx.drawImage(this.imgElement,0,0);

    //Grab the Pixel Data, and prepare it for use
    this.pixelData = this.ctx.getImageData(0,0,this.ctxDimensions.width, this.ctxDimensions.height);
  };
  
  this.coreLoop = function(){
    var x = 0;
    var y = 0;

    var left = undefined;
    var top = undefined;
    var right = undefined;
    var bottom = undefined;

    for(y=0;y<this.pixelData.height;y++){
        for(x=0;x<this.pixelData.width;x++){
            // get this pixel's data
            // currently, we're looking at the blue channel only.
            // Since this is a B/W photo, all color channels are the same.
            // ideally, we would make this work for all channels for color photos.
            index = (x + y * this.ctxDimensions.width) * 4;
            pixel = this.pixelData.data[index+2];

            // Get the values of the surrounding pixels
            // Color data is stored [r,g,b,a][r,g,b,a]
            // in sequence.
            left = this.pixelData.data[index-4];
            right = this.pixelData.data[index+2];
            top = this.pixelData.data[index-(this.ctxDimensions.width*4)];
            bottom = this.pixelData.data[index+(this.ctxDimensions.width*4)];

            //Compare it all.
            // (Currently, just the left pixel)
            if(pixel>left+this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel<left-this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel>right+this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel<right-this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel>top+this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel<top-this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel>bottom+this.threshold){
                this.plotPoint(x,y);
            }
            else if(pixel<bottom-this.threshold){
                this.plotPoint(x,y);
            }
        }
    }
  };
  
  this.plotPoint = function(x,y){
      this.ctx.beginPath();
      this.ctx.arc(x, y, 0.5, 0, 2 * Math.PI, false);
      this.ctx.fillStyle = 'green';
      this.ctx.fill();
      this.ctx.beginPath();

      // Copy onto the raw canvas
      // this is probably the most useful application of this,
      // as you would then have raw data of the edges that can be used.

      this.rawctx.beginPath();
      this.rawctx.arc(x, y, 0.5, 0, 2 * Math.PI, false);
      this.rawctx.fillStyle = 'green';
      this.rawctx.fill();
      this.rawctx.beginPath();
  };
}

var edgeDetector = new edgeDetector();


$(document).ready(function(){
  // Run at start
  edgeDetector.imgElement = $('#image')[0];
  edgeDetector.init();
  edgeDetector.findEdges();
  
  // Run when the threshold changes
  $('#threshold').change(function(){
    edgeDetector.threshold = $(this).val();
    edgeDetector.findEdges();
  });

});
              
            
!
999px

Console