add loading spinner fallback (#202)

* add loading spinner fallback fixes #189

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* handle testing with progress spinners

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* apply fixes and improvements

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* add example

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* bug fixes

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* resolves #189

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2018-03-31 10:51:28 +05:30
committed by Jeffrey Warren
parent fba80bb151
commit 3b791ad58b
20 changed files with 5549 additions and 235 deletions

View File

@@ -1,5 +1,4 @@
const _ = require('lodash')
var pace = require('pace')
//define kernels for the sobel filter
const kernelx = [[-1,0,1],[-2,0,2],[-1,0,1]],
@@ -12,7 +11,6 @@ let weakEdgePixels = []
let notInUI
module.exports = exports = function(pixels,highThresholdRatio,lowThresholdRatio,inBrowser){
notInUI = !inBrowser
if(notInUI) var progressbar1 = pace((pixels.shape[0] * pixels.shape[1]))
for(var x = 0; x < pixels.shape[0]; x++) {
angles.push([])
mags.push([])
@@ -33,7 +31,6 @@ module.exports = exports = function(pixels,highThresholdRatio,lowThresholdRatio
mags.slice(-1)[0].push(pixel[3])
angles.slice(-1)[0].push(result.angle)
if(notInUI)progressbar1.op()
}
}
@@ -75,7 +72,6 @@ function changePixel(pixels,val,a,x,y){
function nonMaxSupress(pixels) {
angles = angles.map((arr)=>arr.map(convertToDegrees))
if(notInUI) var progressbar2 = pace((pixels.shape[0] * pixels.shape[1]))
for(let i = 1;i<pixels.shape[0]-1;i++){
for(let j=1;j<pixels.shape[1]-1;j++){
@@ -118,7 +114,6 @@ function nonMaxSupress(pixels) {
else
pixels.set(i,j,3,0)
if(notInUI) progressbar2.op()
}
}
return pixels
@@ -133,7 +128,6 @@ var findMaxInMatrix = arr => Math.max(...arr.map(el=>el.map(val=>!!val?val:0)).m
function doubleThreshold(pixels,highThresholdRatio,lowThresholdRatio){
const highThreshold = findMaxInMatrix(mags) * 0.2
const lowThreshold = highThreshold * lowThresholdRatio
if(notInUI) var progressbar3 = pace((pixels.shape[0] * pixels.shape[1]))
for(let i =0;i<pixels.shape[0];i++){
for(let j=0;j<pixels.shape[1];j++){
@@ -144,7 +138,6 @@ function doubleThreshold(pixels,highThresholdRatio,lowThresholdRatio){
?strongEdgePixels.push(pixelPos)
:weakEdgePixels.push(pixelPos)
:pixels.set(i,j,3,0)
if(notInUI) progressbar3.op()
}
}