diff --git a/imagelab_electron/operations.js b/imagelab_electron/operations.js index 43d40ed..d1d5fad 100644 --- a/imagelab_electron/operations.js +++ b/imagelab_electron/operations.js @@ -21,6 +21,7 @@ const PROCESS_OPERATIONS = { EROSION: "filtering_erosion", DILATION: "filtering_dilation", MORPHOLOGICAL: "filtering_morphological", + COLORMAPS: "imageconvertions_colormaps", }; module.exports = PROCESS_OPERATIONS; diff --git a/imagelab_electron/src/controller/main.js b/imagelab_electron/src/controller/main.js index 2afe87e..9bf0a5d 100644 --- a/imagelab_electron/src/controller/main.js +++ b/imagelab_electron/src/controller/main.js @@ -21,6 +21,7 @@ const AffineImage = require("../operator/geometric/AffineImage"); const ReflectImage = require("../operator/geometric/ReflectImage"); const RotateImage = require("../operator/geometric/RotateImage"); const ScaleImage = require("../operator/geometric/ScaleImage"); +const ColorMaps = require("../operator/convertions/ColorMaps") class MainController { // This private field is used to store the applied operators in the workspace @@ -209,6 +210,11 @@ class MainController { new Morphological(PROCESS_OPERATIONS.MORPHOLOGICAL, id) ); break; + case PROCESS_OPERATIONS.COLORMAPS: + this.#appliedOperators.push( + new ColorMaps(PROCESS_OPERATIONS.COLORMAPS, id) + ); + break; default: break; } diff --git a/imagelab_electron/src/operator/convertions/ColorMaps.js b/imagelab_electron/src/operator/convertions/ColorMaps.js new file mode 100644 index 0000000..2f0ab0f --- /dev/null +++ b/imagelab_electron/src/operator/convertions/ColorMaps.js @@ -0,0 +1,67 @@ +const OpenCvOperator = require("../OpenCvOperator"); + +/** + * This class contains the main logic to apply simple threshold + * to an image + */ + +class ColorMaps extends OpenCvOperator { + #type = "HOT" + constructor(type, id) { + super(type, id); + } + + setParams(type, value) { + if (type === "type") { + this.#type = value; + } + } + + + /** + * + * @param {Mat} image + * @returns + * + * This function processes simple threshold + * to the mat image + */ + compute(image) { + const dst = new this.cv2.Mat(); + switch (this.#type) { + case "AUTUMN": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_AUTUMN) + break; + case "HOT": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_HOT); + break; + case "BONE": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_BONE); + break; + case "COOL": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_COOL); + break; + case "HSV": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_HSV); + break; + case "JET": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_JET); + break; + case "OCEAN": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_OCEAN); + break; + case "PARULA": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_PARULA); + break; + case "PINK": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_PINK); + break; + case "RAINBOW": + this.cv2.applyColorMap(image, dst, this.cv2.COLORMAP_RAINBOW); + break; + } + return dst; + } +} + +module.exports = ColorMaps; \ No newline at end of file