diff --git a/src/modules/BlobAnalysis/BlobAnalysis.js b/src/modules/BlobAnalysis/BlobAnalysis.js index aa633301..1e79b9e7 100644 --- a/src/modules/BlobAnalysis/BlobAnalysis.js +++ b/src/modules/BlobAnalysis/BlobAnalysis.js @@ -1,6 +1,6 @@ module.exports = function(pixels, options, priorStep){ - var $ = require('jquery'); // to make Blob-analysis work for node.js + var $ = require('jquery'); // To make Blob-analysis work in Node var img = $(priorStep.imgElement); if(Object.keys(img).length === 0){ @@ -25,26 +25,26 @@ module.exports = function(pixels, options, priorStep){ let unknown = new cv.Mat(); let markers = new cv.Mat(); - // gray and threshold image + // Gray and Threshold the image cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0); cv.threshold(gray, gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU); - // get background + // Get background let M = cv.Mat.ones(3, 3, cv.CV_8U); cv.erode(gray, gray, M); cv.dilate(gray, opening, M); cv.dilate(opening, imageBg, M, new cv.Point(-1, -1), 3); - // distance transform + // Distance transform cv.distanceTransform(opening, distTrans, cv.DIST_L2, 5); cv.normalize(distTrans, distTrans, 1, 0, cv.NORM_INF); - // get foreground + // Get foreground cv.threshold(distTrans, imageFg, 0.7 * 1, 255, cv.THRESH_BINARY); imageFg.convertTo(imageFg, cv.CV_8U, 1, 0); cv.subtract(imageBg, imageFg, unknown); - // get connected components markers + // Get connected components markers cv.connectedComponents(imageFg, markers); for (let i = 0; i < markers.rows; i++) { for (let j = 0; j < markers.cols; j++) { @@ -58,13 +58,13 @@ module.exports = function(pixels, options, priorStep){ cv.cvtColor(src, src, cv.COLOR_RGBA2RGB, 0); cv.watershed(src, markers); - // draw barriers + // Grow barriers for (let i = 0; i < markers.rows; i++) { for (let j = 0; j < markers.cols; j++) { if (markers.intPtr(i, j)[0] == -1) { - src.ucharPtr(i, j)[0] = 255; // R - src.ucharPtr(i, j)[1] = 0; // G - src.ucharPtr(i, j)[2] = 0; // B + src.ucharPtr(i, j)[0] = 255; // Red + src.ucharPtr(i, j)[1] = 0; // Green + src.ucharPtr(i, j)[2] = 0; // Blue } } } @@ -78,4 +78,4 @@ module.exports = function(pixels, options, priorStep){ pixels.data = myImageData.data; return pixels; -}; \ No newline at end of file +}; diff --git a/src/modules/BlobAnalysis/Module.js b/src/modules/BlobAnalysis/Module.js index 788b5ec1..f654cdc2 100644 --- a/src/modules/BlobAnalysis/Module.js +++ b/src/modules/BlobAnalysis/Module.js @@ -10,7 +10,7 @@ module.exports = function BlobAnalysis(options, UI){ var step = this; - var priorStep = this.getStep(-1); // get the previous step to process it + var priorStep = this.getStep(-1); // Get the previous step to process it function extraManipulation(pixels){ @@ -40,4 +40,4 @@ module.exports = function BlobAnalysis(options, UI){ output: output, UI: UI }; -}; \ No newline at end of file +};