Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 2ccf4ae

Browse files
committed
Added Duv computation
1 parent 786b582 commit 2ccf4ae

File tree

9 files changed

+62
-20
lines changed

9 files changed

+62
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
ColorSharp's Changelog
22
======================
33

4-
## 2015-02-25 : 0.10.0 Release
4+
## 2015-02-26 : 0.11.0 Release
55

66
### Contributors
77
* Andrés Correa Casablanca <castarco@gmail.com , castarco@litipk.com>
88

9+
### Changes
10+
* Added CCT (Correlated Color Temparature) computation.
11+
* Added Duv (Distance on CIE's 1960 UCS/Yuv color space) computation.
12+
13+
## 2015-02-25 : 0.10.0 Release
14+
915
### Project Handling
1016
* Until we have more contributors, removed the references to contributors for
1117
every release in the CHANGELOG file.

ColorSharp.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ Global
3333
$0.VersionControlPolicy = $2
3434
$2.inheritsSet = Mono
3535
description = A .Net/Mono library to handle color spaces (and light spectrums!)
36-
version = 0.10.0
36+
version = 0.11.0
3737
EndGlobalSection
3838
EndGlobal

ColorSharp/ColorSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<SignAssembly>true</SignAssembly>
1212
<DelaySign>true</DelaySign>
1313
<AssemblyOriginatorKeyFile>colorsharp.pub</AssemblyOriginatorKeyFile>
14-
<ReleaseVersion>0.10.0</ReleaseVersion>
14+
<ReleaseVersion>0.11.0</ReleaseVersion>
1515
</PropertyGroup>
1616
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1717
<DebugSymbols>true</DebugSymbols>

ColorSharp/ColorSharp.nuspec

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1212
<description>$description$</description>
1313
<releaseNotes>
14-
- Added new Illuminants
15-
- Added new Matching Functions
16-
- Improved spectrum -> color conversion mechanism
17-
- Added black body spectrums
18-
- Minor API breaks.
14+
- Added CCT computation.
15+
- Added Duv computation.
1916
</releaseNotes>
2017
<copyright>Copyright 2014-2015</copyright>
2118
<tags>Light Color Colour CIEXYZ CIExyY sRGB</tags>

ColorSharp/src/ColorSpaces/AConvertibleColor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ public virtual double GetCCT ()
137137
return ToCIEUCS ().GetCCT ();
138138
}
139139

140+
public virtual double GetDuv ()
141+
{
142+
if (DataSource is BlackBodySpectrum) {
143+
return 0;
144+
}
145+
146+
return ToCIEUCS ().GetDuv ();
147+
}
148+
140149
/**
141150
* <summary>Converts the color sample to a CIE's 1931 XYZ color sample.</summary>
142151
*/

ColorSharp/src/ColorSpaces/CIEUCS.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public sealed class CIEUCS : AConvertibleColor
7979

8080
static List<CIEUCS> TemperatureChromaticities = null;
8181

82+
double CCT = double.NaN;
83+
84+
double Duv = double.NaN;
85+
8286
#endregion
8387

8488

@@ -188,6 +192,11 @@ public override double GetCCT ()
188192
return (DataSource as BlackBodySpectrum).CCT;
189193
}
190194

195+
if (!double.IsNaN (CCT)) {
196+
return CCT;
197+
}
198+
199+
// Precomputing interpolation tables...
191200
if (TemperatureChromaticities == null) {
192201
// Oversized to improve alignment (needs 302).
193202
TemperatureChromaticities = new List<CIEUCS> (512);
@@ -201,7 +210,7 @@ public override double GetCCT ()
201210
}
202211

203212
int bestI = 0;
204-
double minDuv = double.PositiveInfinity;
213+
Duv = double.PositiveInfinity;
205214

206215
// First gross grained search
207216
// TODO: This is a naive search, must be improved!
@@ -211,12 +220,12 @@ public override double GetCCT ()
211220
Math.Pow (v - TemperatureChromaticities [i].v, 2)
212221
);
213222

214-
if (minDuv > tmpDuv) {
215-
minDuv = tmpDuv;
223+
if (Duv > tmpDuv) {
224+
Duv = tmpDuv;
216225
bestI = i;
217226
}
218227
}
219-
double bestTmp = TemperatureChromaticities [bestI].GetCCT ();
228+
CCT = TemperatureChromaticities [bestI].GetCCT ();
220229

221230
// Preparing the following fine grained search
222231
double tMin = TemperatureChromaticities [
@@ -233,13 +242,26 @@ public override double GetCCT ()
233242

234243
double tmpDuv = Math.Sqrt (Math.Pow (u - tmpUV.u, 2) + Math.Pow (v - tmpUV.v, 2));
235244

236-
if (minDuv > tmpDuv) {
237-
minDuv = tmpDuv;
238-
bestTmp = t;
245+
if (Duv > tmpDuv) {
246+
Duv = tmpDuv;
247+
CCT = t;
239248
}
240249
}
241250

242-
return bestTmp;
251+
return CCT;
252+
}
253+
254+
public override double GetDuv ()
255+
{
256+
if (DataSource is BlackBodySpectrum) {
257+
return 0;
258+
}
259+
260+
if (double.IsNaN (Duv)) {
261+
GetCCT ();
262+
}
263+
264+
return Duv;
243265
}
244266

245267
/**

ColorSharp/src/LightSpectrums/BlackBodySpectrum.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ public override double GetCCT ()
121121
return CCT;
122122
}
123123

124+
/**
125+
* <inheritdoc />
126+
*/
127+
public override double GetDuv ()
128+
{
129+
return 0;
130+
}
131+
124132
#endregion
125133
}
126134
}

ColorSharpTests/ColorSharpTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>Litipk.ColorSharpTests</RootNamespace>
99
<AssemblyName>ColorSharpTests</AssemblyName>
10-
<ReleaseVersion>0.10.0</ReleaseVersion>
10+
<ReleaseVersion>0.11.0</ReleaseVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>

TODO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
* [ ] Color Rendering Index (CRI)
3333

3434
### Colors
35-
* [ ] Color Temperature
35+
* [X] Color Temperature
3636

3737
## Color Operations
38-
* IsAdditive : bool
39-
* colorC = colorA + colorB
38+
* [ ] IsAdditive : bool
39+
* [ ] colorC = colorA + colorB
4040

4141
## Performance
4242
* [ ] Make use of OpenCL to improve conversions performance (with OpenCL.NET?)

0 commit comments

Comments
 (0)