From 2373f2a4fe8ebeb979f21ca952c173806d36459f Mon Sep 17 00:00:00 2001 From: Joe DF <3848219+joedf@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:11:05 -0500 Subject: [PATCH] update jsdocs --- jsdocs/G_MATH_TOFIXED.html | 4 +- jsdocs/NRMSE.html | 4 +- jsdocs/Utils.html | 425 +++++++++++++++++++++++++++++++++---- jsdocs/drawsteps.js.html | 4 +- jsdocs/global.html | 108 ++++++++-- jsdocs/img_metrics.js.html | 4 +- jsdocs/index.html | 4 +- jsdocs/main.js.html | 49 ++++- jsdocs/utils.js.html | 72 ++++++- 9 files changed, 594 insertions(+), 80 deletions(-) diff --git a/jsdocs/G_MATH_TOFIXED.html b/jsdocs/G_MATH_TOFIXED.html index 80b1b50..cc38bbb 100644 --- a/jsdocs/G_MATH_TOFIXED.html +++ b/jsdocs/G_MATH_TOFIXED.html @@ -363,13 +363,13 @@

(static) SHORT<
↑ Top
diff --git a/jsdocs/NRMSE.html b/jsdocs/NRMSE.html index b44012f..76f7a28 100644 --- a/jsdocs/NRMSE.html +++ b/jsdocs/NRMSE.html @@ -746,13 +746,13 @@

Returns:

↑ Top
diff --git a/jsdocs/Utils.html b/jsdocs/Utils.html index f32857d..5fad37d 100644 --- a/jsdocs/Utils.html +++ b/jsdocs/Utils.html @@ -195,7 +195,7 @@

(static)
Source:
@@ -370,7 +370,7 @@
Parameters:
Source:
@@ -632,7 +632,7 @@
Parameters:
Source:
@@ -869,7 +869,7 @@
Parameters:
Source:
@@ -1137,7 +1137,7 @@
Parameters:
Source:
@@ -1235,7 +1235,7 @@

(static) Source:
@@ -1425,6 +1425,189 @@
Parameters:
+ + + + + + +

(static) applyBrightnessContrast(drawable, brightness, contrast)

+ + + + + + +
+ Applies Brightness/Contrast (B/C) values to a given Konva stage or drawable. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
drawable + + +* + + + + The Konva stage or drawable / drawElement.
brightness + + +* + + + + The brightness value, from -1 to 1.
contrast + + +* + + + + The contrast value, mainly from -100 to 100.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1555,7 +1738,7 @@
Parameters:
Source:
@@ -1738,7 +1921,7 @@
Parameters:
Source:
@@ -1908,7 +2091,7 @@
Parameters:
Source:
@@ -2172,7 +2355,7 @@
Parameters:
Source:
@@ -2431,7 +2614,7 @@
Parameters:
Source:
@@ -2851,7 +3034,7 @@
Parameters:
Source:
@@ -3057,7 +3240,7 @@
Parameters:
Source:
@@ -3227,7 +3410,7 @@
Parameters:
Source:
@@ -3456,7 +3639,7 @@
Parameters:
Source:
@@ -3710,7 +3893,7 @@
Parameters:
Source:
@@ -3926,7 +4109,7 @@
Parameters:
Source:
@@ -4096,7 +4279,7 @@
Parameters:
Source:
@@ -4243,7 +4426,7 @@
Parameters:
Source:
@@ -4586,7 +4769,7 @@
Parameters:
Source:
@@ -4626,6 +4809,166 @@
Returns:
+ + + + + + +

(static) getLayerByName(stage, layerName)

+ + + + + + +
+ Finds (non-recusrive) the first layer with a matching on a given stage, null if n/a. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
stage + + +* + + + + The stage or element with layers.
layerName + + +* + + + + The name of the layer.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -4733,7 +5076,7 @@
Parameters:
Source:
@@ -4880,7 +5223,7 @@
Parameters:
Source:
@@ -5027,7 +5370,7 @@
Parameters:
Source:
@@ -5174,7 +5517,7 @@
Parameters:
Source:
@@ -5390,7 +5733,7 @@
Parameters:
Source:
@@ -6005,7 +6348,7 @@
Parameters:
Source:
@@ -6211,7 +6554,7 @@
Parameters:
Source:
@@ -6417,7 +6760,7 @@
Parameters:
Source:
@@ -6632,7 +6975,7 @@
Parameters:
Source:
@@ -6825,7 +7168,7 @@
Parameters:
Source:
@@ -6972,7 +7315,7 @@
Parameters:
Source:
@@ -7119,7 +7462,7 @@
Parameters:
Source:
@@ -7312,7 +7655,7 @@
Parameters:
Source:
@@ -7410,7 +7753,7 @@

(static)
Source:
@@ -7616,7 +7959,7 @@
Parameters:
Source:
@@ -7776,7 +8119,7 @@
Parameters:
Source:
@@ -7936,7 +8279,7 @@
Parameters:
Source:
@@ -8096,7 +8439,7 @@
Parameters:
Source:
@@ -8233,7 +8576,7 @@
Parameters:
Source:
@@ -8286,13 +8629,13 @@
Parameters:

- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/drawsteps.js.html b/jsdocs/drawsteps.js.html index 5dc1fac..3baa7d3 100644 --- a/jsdocs/drawsteps.js.html +++ b/jsdocs/drawsteps.js.html @@ -1144,13 +1144,13 @@

Source: drawsteps.js


- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/global.html b/jsdocs/global.html index e7d0bac..3235baa 100644 --- a/jsdocs/global.html +++ b/jsdocs/global.html @@ -188,7 +188,7 @@

(constant)
Source:
@@ -250,7 +250,7 @@

G
Source:
@@ -312,7 +312,7 @@

G_BOX_SIZE<
Source:
@@ -374,7 +374,7 @@

(constant) Source:
@@ -436,7 +436,7 @@

G
Source:
@@ -498,7 +498,7 @@

G_INPUT_
Source:
@@ -560,7 +560,7 @@

G_MAI
Source:
@@ -629,7 +629,7 @@

G_MAI
Source:
@@ -698,7 +698,7 @@

(constant)
Source:
@@ -767,7 +767,69 @@

(cons
Source:
+ + + + + + + + + + + + + + + + +

G_UpdateFilters

+ + + + +
+ global reference to update/apply image filters +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -829,7 +891,7 @@

G_Up
Source:
@@ -891,7 +953,7 @@

G_Update
Source:
@@ -953,7 +1015,7 @@

Source:
@@ -1015,7 +1077,7 @@

G
Source:
@@ -1077,7 +1139,7 @@

Source:
@@ -1139,7 +1201,7 @@

G_VSEM_P
Source:
@@ -1201,7 +1263,7 @@

G_
Source:
@@ -1263,7 +1325,7 @@

(constant) nSt
Source:
@@ -1513,7 +1575,7 @@

Parameters:
Source:
@@ -1601,7 +1663,7 @@

Resa
Source:
@@ -1696,7 +1758,7 @@

Update
Source:
@@ -3796,13 +3858,13 @@

Returns:

- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/img_metrics.js.html b/jsdocs/img_metrics.js.html index 45ea591..9dab7eb 100644 --- a/jsdocs/img_metrics.js.html +++ b/jsdocs/img_metrics.js.html @@ -207,13 +207,13 @@

Source: img_metrics.js


- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/index.html b/jsdocs/index.html index d4f06dc..51c2087 100644 --- a/jsdocs/index.html +++ b/jsdocs/index.html @@ -167,13 +167,13 @@

References


- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/main.js.html b/jsdocs/main.js.html index ca70fcb..256131c 100644 --- a/jsdocs/main.js.html +++ b/jsdocs/main.js.html @@ -89,6 +89,7 @@

Source: main.js

* G_Update_InfoDisplays * G_update_ImgMetrics * G_UpdateRuler + * G_UpdateFilters * G_AUTO_PREVIEW_LIMIT * G_VSEM_PAUSED * G_IMG_METRIC_ENABLED @@ -162,6 +163,8 @@

Source: main.js

var G_update_ImgMetrics = null; /** global reference to update the ruler */ var G_UpdateRuler = null; +/** global reference to update/apply image filters */ +var G_UpdateFilters = null; /** a global reference to the main body container that holds the boxes/stages. * @todo do we still need this? Maybe remove... */ @@ -369,8 +372,14 @@

Source: main.js

var updateGroundtruthMap = groundtruthMap.updateFunc; G_Update_GroundTruth = updateGroundtruthMap; - // add ruler on Groun truth stage - var rulerLayer = new Konva.Layer({visible: false}); + // add ruler on Ground truth stage + var rulerLayer = Utils.getLayerByName(groundtruthMapStage, 'myRuler'); + if (rulerLayer != null) { + // make sure we don't add a duplicate layer, to avoid memory leaks + // mainly when a new image is loaded. + rulerLayer.destroy(); + } + rulerLayer = new Konva.Layer({visible: false, name: 'myRuler'}); groundtruthMapStage.add(rulerLayer); var ruler = Utils.CreateRuler(rulerLayer, eImg, // Default is a ruler that is 2/3rd width of the stage and vertically in middle @@ -396,6 +405,8 @@

Source: main.js

ruler.doUpdate(); // update the ruler rulerLayer.visible(show); // update visibility }; + // update ruler once immediately + G_UpdateRuler(); // draw Resulting Image $(virtualSEMStage.getContainer()).attr('box_label', 'Resulting Image'); @@ -442,6 +453,36 @@

Source: main.js

doUpdate(); }); + function updateFilters(){ + var doBC = Utils.getGlobalBCInput(); + if (doBC) { + // stages that we want to apply filters to... + var fStages = [ + groundtruthMapStage, baseImageStage, + spotContentStage, probeLayoutStage, + layoutSampledStage + ]; + + // apply the filters + const brightness = Utils.getBrightnessInput(); + const contrast = Utils.getContrastInput(); + for (let i = 0; i < fStages.length; i++) { + const fStage = fStages[i]; + let image = Utils.getFirstImageFromStage(fStage); + Utils.applyBrightnessContrast(image, brightness, contrast); + } + + // for the resulting images, the sampling function, Utils.ComputeProbeValue_gs(), + // is made B/C aware and using Konva's built-in filters directly. + } + + // call global visual update + doUpdate(); + } + // update filters once immediately + updateFilters(); + G_UpdateFilters = updateFilters; + doUpdate(); Utils.updateAdvancedMode(); @@ -572,13 +613,13 @@

Source: main.js


- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top
diff --git a/jsdocs/utils.js.html b/jsdocs/utils.js.html index 8cc3823..0284980 100644 --- a/jsdocs/utils.js.html +++ b/jsdocs/utils.js.html @@ -217,6 +217,9 @@

Source: utils.js

getRowsInput: function(){ return G_GUI_Controller.pixelCountY; }, getColsInput: function(){ return G_GUI_Controller.pixelCountX; }, + getBrightnessInput: function(){ return G_GUI_Controller.brightness; }, + getContrastInput: function(){ return G_GUI_Controller.contrast; }, + getGlobalBCInput: function(){ return G_GUI_Controller.globalBC; }, getCellWInput: function(){ return this.getInputValueInt($('#iCellW')); }, getCellHInput: function(){ return this.getInputValueInt($('#iCellH')); }, getSpotXInput: function(){ return this.getInputValueInt($('#iSpotX')); }, @@ -1578,6 +1581,17 @@

Source: utils.js

// grab the pixel data from the pixel selection area var pxData = ctx.getImageData(0,0,cv.width,cv.height); + // hack to directly use Konva's built-in filters code + if (typeof Konva != 'undefined') { + var brightnessFunc = Konva.Filters.Brighten.bind({ + brightness: () => this.getBrightnessInput()}); + var contrastFunc = Konva.Filters.Contrast.bind({ + contrast: () => this.getContrastInput()}); + // apply it directly to out image data before we sample it. + brightnessFunc(pxData); + contrastFunc(pxData); + } + // compute the average pixel (excluding 0-0-0-0 rgba pixels) var pxColor = this.get_avg_pixel_gs(pxData); @@ -1589,6 +1603,43 @@

Source: utils.js

return pxColor; }, + /** + * Applies Brightness/Contrast (B/C) values to a given Konva stage or drawable. + * @param {*} drawable The Konva stage or drawable / drawElement. + * @param {*} brightness The brightness value, from -1 to 1. + * @param {*} contrast The contrast value, mainly from -100 to 100. + */ + applyBrightnessContrast: function(drawable, brightness=0, contrast=0) { + // cache step is need for filter effects to be visible. + // https://konvajs.org/docs/performance/Shape_Caching.html + drawable.cache(); + + // Filters: https://konvajs.org/api/Konva.Filters.html + // Brightness => https://konvajs.org/docs/filters/Brighten.html + // Contrast => https://konvajs.org/docs/filters/Contrast.html + var currentFilters = drawable.filters(); + // null check, default to empty array if n/a. + currentFilters = currentFilters != null ? currentFilters : []; + // Add filter if not already included... + var currentFiltersByName = currentFilters.map(x => x.name); + var filtersToSet = currentFilters; + var added = 0; + ['Brighten', 'Contrast'].forEach(filterName => { + if (!currentFiltersByName.includes(filterName)) { + filtersToSet.push(Konva.Filters[filterName]); + added++; + } + }); + drawable.filters(filtersToSet); + if (G_DEBUG) { + console.log("filters added:", added); + } + + // apply B/C filter values + drawable.brightness(brightness); + drawable.contrast(contrast); + }, + /** * Find and gets the first "image" type from the first layer of the given Konva stage * @param {*} stage the stage to search through @@ -1602,6 +1653,23 @@

Source: utils.js

return image; }, + /** + * Finds (non-recusrive) the first layer with a matching on a given stage, null if n/a. + * @param {*} stage The stage or element with layers. + * @param {*} layerName The name of the layer. + */ + getLayerByName: function(stage, layerName){ + var layers = stage.getLayers(); + for (let i = 0; i < layers.length; i++) { + const layer = layers[i]; + const name = layer.name(); + if (name == layerName) { + return layer; + } + } + return null; + }, + /** * get the image without the row/draw indicator * @param {*} stage the stage to search through @@ -1717,13 +1785,13 @@

Source: utils.js


- Documentation generated by JSDoc 4.0.2 on Tue Oct 31 2023 22:45:12 GMT-0400 (Eastern Daylight Time) + Documentation generated by JSDoc 4.0.2 on Wed Nov 15 2023 13:10:54 GMT-0500 (Eastern Standard Time)
↑ Top