Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions imagelab_electron/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const PROCESS_OPERATIONS = {
EROSION: "filtering_erosion",
DILATION: "filtering_dilation",
MORPHOLOGICAL: "filtering_morphological",
COLORMAPS: "imageconvertions_colormaps",
};

module.exports = PROCESS_OPERATIONS;
6 changes: 6 additions & 0 deletions imagelab_electron/src/controller/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
67 changes: 67 additions & 0 deletions imagelab_electron/src/operator/convertions/ColorMaps.js
Original file line number Diff line number Diff line change
@@ -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;