Added Eslint and husky (#1062)

This commit is contained in:
aashna27
2019-05-11 20:09:15 +05:30
committed by Jeffrey Warren
parent 0c3d7be7e2
commit c784de0c19
203 changed files with 3288 additions and 3250 deletions

View File

@@ -1,14 +1,14 @@
// Define kernels for the sobel filter
const kernelx = [
[-1, 0, 1],
[-2, 0, 2],
[-1, 0, 1]
],
kernely = [
[-1,-2,-1],
[ 0, 0, 0],
[ 1, 2, 1]
];
[-1, 0, 1],
[-2, 0, 2],
[-1, 0, 1]
],
kernely = [
[-1,-2,-1],
[ 0, 0, 0],
[ 1, 2, 1]
];
let pixelsToBeSupressed = [];
@@ -39,7 +39,7 @@ module.exports = function(pixels, highThresholdRatio, lowThresholdRatio, useHyst
pixelsToBeSupressed.forEach(pixel => supress(pixels, pixel));
return pixels;
}
};
function supress(pixels, pixel) {
@@ -84,7 +84,7 @@ function sobelFilter(pixels, x, y) {
return {
pixel: [val, val, val, grad],
angle: angle
}
};
}
function categorizeAngle(angle){
@@ -108,8 +108,8 @@ function isOutOfBounds(pixels, x, y){
const removeElem = (arr = [], elem) => {
return arr = arr.filter((arrelem) => {
return arrelem !== elem;
})
}
});
};
// Non Maximum Supression without interpolation
function nonMaxSupress(pixels, grads, angles) {
@@ -122,29 +122,29 @@ function nonMaxSupress(pixels, grads, angles) {
if (!isOutOfBounds(pixels, x - 1, y - 1) && !isOutOfBounds(pixels, x+1, y+1)){
switch (angleCategory){
case 1:
if (!((grads[x][y] >= grads[x][y + 1]) && (grads[x][y] >= grads[x][y - 1]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
case 1:
if (!((grads[x][y] >= grads[x][y + 1]) && (grads[x][y] >= grads[x][y - 1]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
case 2:
if (!((grads[x][y] >= grads[x + 1][y + 1]) && (grads[x][y] >= grads[x - 1][y - 1]))){
pixelsToBeSupressed.push([x, y]);
}
break;
case 2:
if (!((grads[x][y] >= grads[x + 1][y + 1]) && (grads[x][y] >= grads[x - 1][y - 1]))){
pixelsToBeSupressed.push([x, y]);
}
break;
case 3:
if (!((grads[x][y] >= grads[x + 1][y]) && (grads[x][y] >= grads[x - 1][y]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
case 3:
if (!((grads[x][y] >= grads[x + 1][y]) && (grads[x][y] >= grads[x - 1][y]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
case 4:
if (!((grads[x][y] >= grads[x + 1][y - 1]) && (grads[x][y] >= grads[x - 1][y + 1]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
case 4:
if (!((grads[x][y] >= grads[x + 1][y - 1]) && (grads[x][y] >= grads[x - 1][y + 1]))) {
pixelsToBeSupressed.push([x, y]);
}
break;
}
}
}
@@ -154,7 +154,7 @@ function nonMaxSupress(pixels, grads, angles) {
var convertToDegrees = radians => (radians * 180) / Math.PI;
// Finds the max value in a 2d array like grads
var findMaxInMatrix = arr => Math.max(...arr.map(el => el.map(val => !!val ? val : 0)).map(el => Math.max(...el)));
var findMaxInMatrix = arr => Math.max(...arr.map(el => el.map(val => val ? val : 0)).map(el => Math.max(...el)));
// Applies the double threshold to the image
function doubleThreshold(pixels, highThresholdRatio, lowThresholdRatio, grads, strongEdgePixels, weakEdgePixels) {
@@ -198,5 +198,5 @@ function hysteresis(strongEdgePixels, weakEdgePixels){
else if(weakEdgePixels.includes([x, y-1])) {
removeElem(weakEdgePixels, [x, y-1]);
}
})
});
}