@@ -8,7 +8,7 @@ import CoreImage
88import CoreImage. CIFilterBuiltins
99import CoreGraphics
1010
11-
11+ /// Predefined color mapping for the 'Jet' colormap style
1212let jetColormap : [ ( r: Float , g: Float , b: Float ) ] = [
1313 ( 0.0 , 0.0 , 0.5 ) , // Dark Blue
1414 ( 0.0 , 0.0 , 1.0 ) , // Blue
@@ -20,6 +20,7 @@ let jetColormap: [(r: Float, g: Float, b: Float)] = [
2020 ( 1.0 , 0.0 , 0.0 ) // Red
2121]
2222
23+ /// Predefined color mapping for the 'Inferno' colormap style
2324let infernoColormap : [ ( r: Float , g: Float , b: Float ) ] = [
2425 ( 0.0 , 0.0 , 0.13 ) , // Dark Purple
2526 ( 0.23 , 0.0 , 0.38 ) , // Deep Red
@@ -28,6 +29,7 @@ let infernoColormap: [(r: Float, g: Float, b: Float)] = [
2829 ( 1.0 , 0.99 , 0.0 ) // Bright Yellow
2930]
3031
32+ /// Predefined color mapping for the 'Viridis' colormap style
3133let viridisColormap : [ ( r: Float , g: Float , b: Float ) ] = [
3234 ( 0.13 , 0.13 , 0.38 ) , // Dark Purple
3335 ( 0.24 , 0.29 , 0.56 ) , // Deep Blue
@@ -36,6 +38,7 @@ let viridisColormap: [(r: Float, g: Float, b: Float)] = [
3638 ( 0.88 , 0.98 , 0.26 ) // Bright Yellow
3739]
3840
41+ /// Predefined color mapping for the 'Plasma' colormap style
3942let plasmaColormap : [ ( r: Float , g: Float , b: Float ) ] = [
4043 ( 0.0 , 0.0 , 0.13 ) , // Dark Purple
4144 ( 0.26 , 0.02 , 0.42 ) , // Deep Pink
@@ -44,6 +47,7 @@ let plasmaColormap: [(r: Float, g: Float, b: Float)] = [
4447 ( 1.0 , 0.99 , 0.0 ) // Bright Yellow
4548]
4649
50+ /// Predefined color mapping for the 'Coolwarm' colormap style
4751let coolwarmColormap : [ ( r: Float , g: Float , b: Float ) ] = [
4852 ( 0.0 , 0.0 , 0.5 ) , // Dark Blue
4953 ( 0.0 , 0.0 , 1.0 ) , // Blue
@@ -52,6 +56,7 @@ let coolwarmColormap: [(r: Float, g: Float, b: Float)] = [
5256 ( 1.0 , 0.0 , 0.0 ) // Red
5357]
5458
59+ /// Predefined color mapping for the 'Magma' colormap style
5560let magmaColormap : [ ( r: Float , g: Float , b: Float ) ] = [
5661 ( 0.0 , 0.0 , 0.13 ) , // Dark Purple
5762 ( 0.25 , 0.0 , 0.27 ) , // Purple
@@ -60,6 +65,7 @@ let magmaColormap: [(r: Float, g: Float, b: Float)] = [
6065 ( 1.0 , 0.91 , 0.0 ) // Light Yellow
6166]
6267
68+ /// Predefined color mapping for the 'Twilight' colormap style
6369let twilightColormap : [ ( r: Float , g: Float , b: Float ) ] = [
6470 ( 0.0 , 0.0 , 0.5 ) , // Dark Blue
6571 ( 0.0 , 0.0 , 1.0 ) , // Blue
@@ -68,35 +74,54 @@ let twilightColormap: [(r: Float, g: Float, b: Float)] = [
6874 ( 1.0 , 1.0 , 0.0 ) // Yellow
6975]
7076
77+ /// Predefined color mapping for the 'Autumn' colormap style
7178let autumnColormap : [ ( r: Float , g: Float , b: Float ) ] = [
7279 ( 1.0 , 1.0 , 0.0 ) , // Yellow
7380 ( 1.0 , 0.5 , 0.0 ) , // Orange
7481 ( 1.0 , 0.0 , 0.0 ) // Red
7582]
7683
84+ /// Predefined color mapping for the 'Spring' colormap style
7785let springColormap : [ ( r: Float , g: Float , b: Float ) ] = [
7886 ( 1.0 , 0.0 , 1.0 ) , // Magenta
7987 ( 1.0 , 1.0 , 0.0 ) // Yellow
8088]
8189
90+ /// Predefined color mapping for the 'Winter' colormap style
8291let winterColormap : [ ( r: Float , g: Float , b: Float ) ] = [
8392 ( 0.0 , 0.0 , 1.0 ) , // Blue
8493 ( 0.0 , 1.0 , 0.0 ) // Green
8594]
8695
96+ /// A class that defines a color mapping for thermal image visualization.
97+ ///
98+ /// ColorMap provides functionality to:
99+ /// - Define a named set of colors for thermal visualization
100+ /// - Convert grayscale thermal data to color using Core Image filters
101+ /// - Support comparison and hashing for collection storage
87102class ColorMap : Hashable , Equatable {
103+ /// Compares two ColorMap instances for equality based on their names.
88104 static func == ( lhs: ColorMap , rhs: ColorMap ) -> Bool {
89105 return lhs. name == rhs. name
90106 }
91107
108+ /// Generates a hash value for the ColorMap based on its name.
92109 func hash( into hasher: inout Hasher ) {
93110 name. hash ( into: & hasher)
94111 }
95112
113+ /// The name of the color map (e.g., "Viridis", "Plasma")
96114 let name : String
115+ /// The array of RGB color values defining the color mapping
97116 let colors : [ ( r: Float , g: Float , b: Float ) ]
117+ /// The Core Image filter used to apply the color mapping
98118 let filter : CIColorCurves
99119
120+ /// Creates a new ColorMap instance.
121+ ///
122+ /// - Parameters:
123+ /// - name: The name of the color map
124+ /// - colors: An array of RGB color values defining the mapping
100125 init ( name: String , colors: [ ( r: Float , g: Float , b: Float ) ] ) {
101126 self . name = name
102127 self . colors = colors
@@ -114,6 +139,7 @@ class ColorMap: Hashable, Equatable {
114139 }
115140}
116141
142+ /// The collection of available color maps for thermal visualization
117143let colorMaps = [
118144 ColorMap ( name: " Viridis " , colors: viridisColormap) ,
119145 ColorMap ( name: " Plasma " , colors: plasmaColormap) ,
0 commit comments