diff --git a/Viewer/lib/components/ig-image-graph.js b/Viewer/lib/components/ig-image-graph.js index 2121893d..a744529c 100644 --- a/Viewer/lib/components/ig-image-graph.js +++ b/Viewer/lib/components/ig-image-graph.js @@ -39,15 +39,18 @@ var object = require('lib/object') var Filters = module.Filters = { makeCanvas: function(w, h, canvas){ - var c = canvas || document.createElement('canvas') + var c = canvas + || document.createElement('canvas') c.width = w c.height = h return c }, // as input takes an HTML Image object... getPixels: function(img, tmp_canvas, w, h){ - var w = w || img.naturalWidth - var h = h || img.naturalHeight + var w = w + || img.naturalWidth + var h = h + || img.naturalHeight var c = this.makeCanvas(w, h, tmp_canvas) var context = c.getContext('2d') if(img == null){ @@ -58,8 +61,10 @@ module.Filters = { context.drawImage(img, 0, 0, w, h) } return context.getImageData(0, 0, c.width, c.height) }, setPixels: function(c, data, w, h){ - w = c.width = w || data.width - h = c.height = h || data.height + w = c.width = w + || data.width + h = c.height = h + || data.height var context = c.getContext('2d') context.putImageData(data, 0, 0) }, @@ -72,10 +77,13 @@ module.Filters = { // focusImage: 2 // showMetadata getNormalizedPixels: function(img, tmp_canvas, s, rotate, flip){ - s = s || Math.max(img.naturalWidth, img.naturalHeight) - rotate = rotate || 0 + s = s + || Math.max(img.naturalWidth, img.naturalHeight) + rotate = rotate + || 0 - ;(rotate == 90 || rotate == 270) + ;(rotate == 90 + || rotate == 270) && (flip = flip == 'horizontal' ? 'vertical' : flip == 'vertical' ? @@ -116,13 +124,17 @@ module.Filters = { var b = d[i+2] // CIE luminance for the RGB // The human eye is bad at seeing red and blue, so we de-emphasize them. - var v = 0.2126*r + 0.7152*g + 0.0722*b + var v = 0.2126*r + + 0.7152*g + + 0.0722*b d[i] = d[i+1] = d[i+2] = v } return pixels }, // XXX need to resize this... histogram: function(pixels, mode, color){ - color = color || 'fill' - mode = mode || 'luminance' + color = color + || 'fill' + mode = mode + || 'luminance' var size = 255 var w = size @@ -148,11 +160,14 @@ module.Filters = { count[v] = count[v+1] = count[v+2] = (count[v] || 0) + 1 } else { - if(mode == 'color' || mode == 'R'){ + if(mode == 'color' + || mode == 'R'){ count[r*4] = (count[r*4] || 0) + 1 } - if(mode == 'color' || mode == 'G'){ + if(mode == 'color' + || mode == 'G'){ count[g*4+1] = (count[g*4+1] || 0) + 1 } - if(mode == 'color' || mode == 'B'){ + if(mode == 'color' + || mode == 'B'){ count[b*4+2] = (count[b*4+2] || 0) + 1 } } } var m = size / Math.max(...count.filter(function(){ return true })) @@ -179,8 +194,10 @@ module.Filters = { return out }, waveform: function(pixels, mode, color){ - mode = mode || 'luminance' - color = color || 'normalized' + mode = mode + || 'luminance' + color = color + || 'normalized' var w = pixels.width var h = pixels.height @@ -225,20 +242,17 @@ module.Filters = { var Bl = 0.0722 for(var i=0; i