mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-16 05:10:00 +01:00
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:
committed by
Jeffrey Warren
parent
fba80bb151
commit
3b791ad58b
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user