[GCI] Standardised Blob Analysis module comments (#1351)

* fix comments

* Update src/modules/BlobAnalysis/BlobAnalysis.js

Fix double image

* Update src/modules/BlobAnalysis/BlobAnalysis.js

* . fix
This commit is contained in:
Harsh Khandeparkar
2019-12-16 17:47:25 +00:00
committed by Jeffrey Warren
parent 3d4025fd93
commit 0ce2cf9492
2 changed files with 13 additions and 13 deletions

View File

@@ -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
}
}
}

View File

@@ -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){