Skip to content

Commit 03e3772

Browse files
authored
Merge pull request #147 from LudmilaKrejcova/master
Methods Ambalathankandy21, Yu21, Zhang08 and Hafner16
2 parents 8b0cf07 + 158d4ad commit 03e3772

22 files changed

+2229
-19
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ cmake_install.cmake
5555
install_manifest.txt
5656
compile_commands.json
5757
CTestTestfile.cmake
58-
test
58+
test
59+
/.vscode
60+
*.dot
61+
/html
62+
/latex

CMakeLists.txt

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@ endif(DOXYGEN_FOUND)
2323
add_subdirectory(tmolib/)
2424
add_subdirectory(TMOgui/)
2525
add_subdirectory(TMOCmd/)
26-
add_subdirectory(TMOWard94/)
27-
add_subdirectory(TMOZhao10/)
26+
27+
#add_subdirectory(TMOWard94/)
28+
#add_subdirectory(TMOZhao10/)
2829
#add_subdirectory(TMOMM16/) #Martin Molek
2930
#add_subdirectory(TMOAlsam06/) #Jiri Zverina
3031
add_subdirectory(TMOAlsam09/) #Martin Molek
3132
add_subdirectory(TMOAncuti16/) #Vladimir Vlkovic
3233
add_subdirectory(TMOAncuti19/) #Lucie Svobodova
3334
#add_subdirectory(TMOCheryl11/) #Vaclav Chvila
3435
#add_subdirectory(TMOFarbman08/) #Tomas Hudziec
35-
add_subdirectory(TMOAubry14/) #Tomas Hudziec
36-
add_subdirectory(TMOKou15/) #Tomas Hudziec
37-
add_subdirectory(TMOMeylan06/)
38-
add_subdirectory(TMODrago03/) #David Chocholaty
39-
add_subdirectory(TMOParis11/) #David Chocholaty
40-
add_subdirectory(TMOGastal11/) #David Chocholaty
41-
add_subdirectory(TMOShan10/) #David Chocholaty
36+
#add_subdirectory(TMOAubry14/) #Tomas Hudziec
37+
#add_subdirectory(TMOKou15/) #Tomas Hudziec
38+
#add_subdirectory(TMOMeylan06/)
39+
#add_subdirectory(TMODrago03/) #David Chocholaty
40+
#add_subdirectory(TMOParis11/) #David Chocholaty
41+
#add_subdirectory(TMOGastal11/) #David Chocholaty
42+
#add_subdirectory(TMOShan10/) #David Chocholaty
4243
#add_subdirectory(TMOXia18/) #David Chocholaty
4344
add_subdirectory(TMOYee03/) #Matus Bicanovsky
4445
add_subdirectory(TMOChen05/) #Matus Bicanovsky
@@ -55,22 +56,22 @@ add_subdirectory(TMOAncuti11/) #Matus Bicanovsky
5556
add_subdirectory(TMOHsin11/) #Matus Bicanovsky
5657
#add_subdirectory(TMOYourOperatorNameLinux/)
5758
#add_subdirectory(TMOJin14/) #
58-
add_subdirectory(TMOLee10/) #Martin Molek
59-
add_subdirectory(TMOKim09/) #Petr Pospisil: method 1/Vladimir Vlkovic
60-
add_subdirectory(TMOZheng15/) #Petr Pospisil: method 2
59+
#add_subdirectory(TMOLee10/) #Martin Molek
60+
#add_subdirectory(TMOKim09/) #Petr Pospisil: method 1/Vladimir Vlkovic
61+
#add_subdirectory(TMOZheng15/) #Petr Pospisil: method 2
6162
#add_subdirectory(TMOBae06/) #Petr Pospisil: method 3 (problem with gui, gui doesnt support TMOString parameter)
62-
add_subdirectory(TMOBiswas05/) #Tomas Chlubna
63+
#add_subdirectory(TMOBiswas05/) #Tomas Chlubna
6364
#add_subdirectory(TMOCadik08/) #Martin Cadik/Jan Brida: OpenCL implementation (CPU and GPU versions)
64-
add_subdirectory(TMOXiong17/) #Filip Brezna: method 1
65-
add_subdirectory(TMOZhongping15/) #Filip Brezna: method 2
65+
#add_subdirectory(TMOXiong17/) #Filip Brezna: method 1
66+
#add_subdirectory(TMOZhongping15/) #Filip Brezna: method 2
6667
#add_subdirectory(TMOJin17/) #Filip Brezna: method 3
6768
add_subdirectory(TMOHu14/) #Vladimir Vlkovic
6869
#add_subdirectory(TMOTao17/) #Vladimir Vlkovic not ready
6970
#add_subdirectory(TMOSon14/) #Sedlar Pavel, Tomas Hudziec
70-
add_subdirectory(TMOCLAHE/) #Sedlar Pavel
71+
#add_subdirectory(TMOCLAHE/) #Sedlar Pavel
7172
#add_subdirectory(TMOKuhn08/) #Pavel Melcer
72-
add_subdirectory(TMOEisemann04/) #Roman Jaska
73-
add_subdirectory(TMOTai08/) #Michal Vlnas
73+
#add_subdirectory(TMOEisemann04/) #Roman Jaska
74+
#add_subdirectory(TMOTai08/) #Michal Vlnas
7475
#add_subdirectory(TMONguy15/) #Matej Valek
7576
#add_subdirectory(TMOWu24/) #Filip Sapak
7677
#add_subdirectory(TMOWu24_2/) #Branislav Dubec
@@ -80,6 +81,10 @@ add_subdirectory(TMOMikamo14/) #Jan Findra
8081
add_subdirectory(TMOSlomp12/) #Jan Findra
8182
add_subdirectory(TMOThompson02/) #Jan Findra
8283
add_subdirectory(TMOKhan20/) #Milan Tichavský
84+
add_subdirectory(TMOAmbalathankandy21/) #Ludmila Krejcova
85+
add_subdirectory(TMOYu21/) #Ludmila Krejcova
86+
add_subdirectory(TMOZhang08/) #Ludmila Krejcova
87+
add_subdirectory(TMOHafner16/) #Ludmila Krejcova
8388

8489
INSTALL(FILES tmolib/libtmo.so DESTINATION lib)
8590
INSTALL(FILES TMOgui/tmogui PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION . )

TMOAmbalathankandy21/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
SET(CMAKE_COLOR_MAKEFILE ON)
2+
SET(CMAKE_VERBOSE_MAKEFILE ON)
3+
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
4+
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
6+
7+
IF(UNIX AND NOT LINUX_SET)
8+
ADD_DEFINITIONS(-D LINUX)
9+
ENDIF(UNIX AND NOT LINUX_SET)
10+
11+
INCLUDE_DIRECTORIES(
12+
../tmolib/
13+
.
14+
)
15+
16+
LINK_LIBRARIES (
17+
tmo
18+
)
19+
20+
SET(SOURCES
21+
TMOAmbalathankandy21.cpp
22+
TMOPlugin.cpp
23+
)
24+
25+
26+
SET(HEADERS
27+
TMOAmbalathankandy21.h
28+
TMOPlugin.h
29+
)
30+
31+
add_library( Ambalathankandy21 SHARED ${SOURCES} ${HEADERS})
32+
add_custom_command( TARGET Ambalathankandy21 POST_BUILD
33+
COMMAND cp -f libAmbalathankandy21.so ../TMOCmd/Ambalathankandy21.tml
34+
COMMAND cp -f libAmbalathankandy21.so ../TMOgui/Ambalathankandy21.tml
35+
COMMAND cp -f libAmbalathankandy21.so ../Ambalathankandy21.tml
36+
# COMMAND rm -f libqueiroz06.so
37+
)
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*******************************************************************************
2+
* *
3+
* Brno University of Technology *
4+
* Faculty of Information Technology *
5+
* *
6+
* Color-to-Grayscale Conversions *
7+
* *
8+
* Author: Ludmila Krejcova [xkrejc85 AT stud.fit.vutbr.cz] *
9+
* Brno 2025 *
10+
* *
11+
* Implementation of the TMOAmbalathankandy21 class *
12+
* *
13+
* A color temperature-based high-speed decolorization: *
14+
* an empirical approach for tone mapping applications *
15+
* https://doi.org/10.48550/arXiv.2108.13656 *
16+
* *
17+
*******************************************************************************/
18+
19+
#include "TMOAmbalathankandy21.h"
20+
#include <fstream>
21+
22+
23+
TMOAmbalathankandy21::TMOAmbalathankandy21()
24+
{
25+
SetName(L"Ambalathankandy21");
26+
SetDescription(L"A color temperature-based high-speed decolorization");
27+
28+
HDRParameter.SetName(L"HDR");
29+
HDRParameter.SetDescription(L"is input image HDR");
30+
HDRParameter.SetDefault(false);
31+
HDRParameter = false;
32+
33+
this->Register(HDRParameter);
34+
}
35+
36+
TMOAmbalathankandy21::~TMOAmbalathankandy21()
37+
{
38+
}
39+
40+
// Computes the minimum and maximum values in the image for normalization
41+
std::pair<double, double> TMOAmbalathankandy21::getImageMinMax(TMOImage &image)
42+
{
43+
double min(std::numeric_limits<double>::max());
44+
double max(-max);
45+
46+
auto data = image.GetData();
47+
for(size_t i = 0; i < 3 * image.GetWidth() * image.GetHeight(); ++i)
48+
{
49+
double value = *data++;
50+
min = std::min(min, value);
51+
max = std::max(max, value);
52+
}
53+
54+
return std::make_pair(min, max);
55+
}
56+
57+
// Normalizes the grayscale image (not part of the original article, added for comparison)
58+
void TMOAmbalathankandy21::normalizeGrayscaleImage(TMOImage &image)
59+
{
60+
auto minmax = getImageMinMax(image);
61+
62+
double min(minmax.first);
63+
double max(minmax.second);
64+
65+
if(max > min)
66+
{
67+
auto data = image.GetData();
68+
double invRange(1.0 / (max - min));
69+
70+
for(size_t i = 0; i < 3 * image.GetWidth() * image.GetHeight(); ++i)
71+
{
72+
*data++ = (*data - min) * invRange;
73+
}
74+
}
75+
}
76+
77+
// Finds if range is 0-1 or in 0-255
78+
bool TMOAmbalathankandy21::isInRange0to1(double *pSourceData, int numPix)
79+
{
80+
for (int i = 0; i < numPix * 3; i++)
81+
{
82+
if(pSourceData[i] > 1)
83+
return false;
84+
}
85+
return true;
86+
}
87+
88+
89+
/* --------------------------------------------------------------------------- *
90+
* Applies the tone mapping operator to transform the image. *
91+
* --------------------------------------------------------------------------- */
92+
int TMOAmbalathankandy21::Transform()
93+
{
94+
double *pSourceData = pSrc->GetData();
95+
double *pDestinationData = pDst->GetData();
96+
97+
double R, G, B, L_White, L_RG, L_Warm, L_Cool, L_B, L;
98+
99+
// Constants based on the reference article
100+
double betaR = 0.55;
101+
double betaK = 0.7;
102+
103+
bool range0to1 = isInRange0to1(pSourceData, pSrc->GetHeight() * pSrc->GetWidth());
104+
105+
// Iterate over each pixel in the image
106+
for (int j = 0; j < pSrc->GetHeight(); j++)
107+
{
108+
pSrc->ProgressBar(j, pSrc->GetHeight()); // Progress bar
109+
for (int i = 0; i < pSrc->GetWidth(); i++)
110+
{
111+
// Read RGB values from the input image
112+
R = *pSourceData++;
113+
G = *pSourceData++;
114+
B = *pSourceData++;
115+
116+
// If format is in range 0-255
117+
if (!range0to1 && !HDRParameter)
118+
{
119+
R /= 255;
120+
G /= 255;
121+
B /= 255;
122+
}
123+
124+
// Compute luminance components
125+
L_White = sqrt((R*R + G*G + B*B)/3);
126+
L_B = B;
127+
L_RG = sqrt(betaR * R * R + (1 - betaR) * G * G);
128+
L_Warm = R / (R + G + B)*L_RG + (1 - R / (R + G + B)) * L_White;
129+
L_Cool = (1 - B / (R + G + B))*L_B + B/(R + G + B) * L_White;
130+
L = sqrt(betaK *L_Warm * L_Warm + (1 - betaK) * L_Cool * L_Cool);
131+
132+
//L = 0.299 * R + 0.587 * G + 0.114 * B;
133+
134+
// Store the computed luminance as grayscale output
135+
*pDestinationData++ = L;
136+
*pDestinationData++ = L;
137+
*pDestinationData++ = L;
138+
}
139+
}
140+
141+
// Optional: Normalize the output image (not part of the original article)
142+
//normalizeGrayscaleImage(*pDst);
143+
return 0;
144+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* *
3+
* Brno University of Technology *
4+
* Faculty of Information Technology *
5+
* *
6+
* Color-to-Grayscale Conversions *
7+
* *
8+
* Author: Ludmila Krejcova [xkrejc85 AT stud.fit.vutbr.cz] *
9+
* Brno 2025 *
10+
* *
11+
* Implementation of the TMOAmbalathankandy21 class *
12+
* *
13+
* A color temperature-based high-speed decolorization: *
14+
* an empirical approach for tone mapping applications *
15+
* https://doi.org/10.48550/arXiv.2108.13656 *
16+
* *
17+
*******************************************************************************/
18+
19+
20+
#include <TMO.h>
21+
22+
class TMOAmbalathankandy21 : public TMO
23+
{
24+
public:
25+
TMOAmbalathankandy21();
26+
27+
28+
virtual ~TMOAmbalathankandy21();
29+
virtual int Transform() override;
30+
31+
// Normalizes the grayscale image (not part of the original article, added for compariso
32+
void normalizeGrayscaleImage(TMOImage &image);
33+
34+
// Computes the minimum and maximum values in the image for normalization
35+
std::pair<double, double> getImageMinMax(TMOImage &image);
36+
37+
// Finds if range is 0-1 or in 0-255
38+
bool isInRange0to1(double *pSourceData, int numPix);
39+
40+
protected:
41+
TMOBool HDRParameter;
42+
};

TMOAmbalathankandy21/TMOPlugin.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* -------------------------------------------------------------------- *
2+
* TMOPlugin.cpp : Template for tone mapping operator plugin *
3+
* in Tone Mapping Studio 2004 *
4+
* -------------------------------------------------------------------- *
5+
* *
6+
* Put this file into a DLL project with your plugin functions and *
7+
* replace commented sections below. *
8+
* *
9+
* Add this preprocesor definition to the project setings : *
10+
* *
11+
* TMOPLUGIN_EXPORTS *
12+
* *
13+
* -------------------------------------------------------------------- */
14+
#include "./TMOPlugin.h"
15+
16+
/* -------------------------------------------------------------------- *
17+
* Insert your operator header below *
18+
* -------------------------------------------------------------------- */
19+
#include "./TMOAmbalathankandy21.h"
20+
21+
/* -------------------------------------------------------------------- *
22+
* Insert a number of implemented operators *
23+
* -------------------------------------------------------------------- */
24+
int iOperatorCount = 1;
25+
26+
/* -------------------------------------------------------------------- *
27+
* DLL Entry point; no changes necessary *
28+
* -------------------------------------------------------------------- */
29+
/*
30+
BOOL APIENTRY DllMain( HANDLE hModule,
31+
DWORD ul_reason_for_call,
32+
LPVOID lpReserved
33+
)
34+
{
35+
switch (ul_reason_for_call)
36+
{
37+
case DLL_PROCESS_ATTACH:
38+
case DLL_THREAD_ATTACH:
39+
case DLL_THREAD_DETACH:
40+
case DLL_PROCESS_DETACH:
41+
break;
42+
}
43+
return TRUE;
44+
}
45+
*/
46+
/* -------------------------------------------------------------------- *
47+
* Returns a number of implemented operators; no changes necessary *
48+
* -------------------------------------------------------------------- */
49+
int TMOPLUGIN_API OperatorCount()
50+
{
51+
return iOperatorCount;
52+
}
53+
54+
/* -------------------------------------------------------------------- *
55+
* For each implemented operator create a new object in field operators,*
56+
* then return number of created operators *
57+
* For exemple : *
58+
* *
59+
* operators[0] = new TMOOperator1; *
60+
* operators[1] = new TMOOperator2; *
61+
* . *
62+
* . *
63+
* . *
64+
* -------------------------------------------------------------------- */
65+
int TMOPLUGIN_API EnumOperators(TMO **operators)
66+
{
67+
operators[0] = new TMOAmbalathankandy21;
68+
return iOperatorCount;
69+
}
70+
71+
/* -------------------------------------------------------------------- *
72+
* Deletes operators; no changes necessary *
73+
* -------------------------------------------------------------------- */
74+
int TMOPLUGIN_API DeleteOperators(TMO **operators)
75+
{
76+
int i;
77+
for (i = 0; i < iOperatorCount; i++)
78+
delete operators[i];
79+
return iOperatorCount;
80+
}

0 commit comments

Comments
 (0)