Skip to content

Methods Ambalathankandy21, Yu21, Zhang08 and Hafner16 #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
947a28b
Added color temperature-based high-speed decolorization
Oct 4, 2024
96f8117
Renamed plugin
LudmilaKrejcova Nov 15, 2024
3af961b
Adding first part of a new method
LudmilaKrejcova Nov 16, 2024
b295de2
Computing rest of the constants
LudmilaKrejcova Nov 17, 2024
22d8e4b
Computing pixel pairs, controling contrast picture
LudmilaKrejcova Nov 21, 2024
4efbc0c
Finalizing Yu21 according the method
LudmilaKrejcova Dec 1, 2024
e3cb5e9
Resize is fixed, some small mistakes fixed
LudmilaKrejcova Dec 20, 2024
7bdf060
Corrected mistakes
LudmilaKrejcova Dec 20, 2024
7e60463
Correcting my mistakes, trying solve their mistakes
LudmilaKrejcova Dec 26, 2024
3ebfcbe
Subimage saving.
LudmilaKrejcova Dec 26, 2024
26d4338
Merge branch 'master' of https://github.com/LudmilaKrejcova/TMS
LudmilaKrejcova Dec 26, 2024
4abee6f
Bugfixes - parameters normalization commented, trying the more logica…
LudmilaKrejcova Dec 28, 2024
d7ce421
Correlation cefficients computation fix.
LudmilaKrejcova Dec 29, 2024
a9204f6
Parameters normalization - stage 1
LudmilaKrejcova Dec 30, 2024
c3e2c30
Better contrast image
LudmilaKrejcova Dec 30, 2024
806f2ec
Contstants changed, refactored code
LudmilaKrejcova Jan 12, 2025
ef3d640
Format
LudmilaKrejcova Feb 10, 2025
c501c6e
Merge remote-tracking branch 'upstream/master'
LudmilaKrejcova Feb 12, 2025
8c5d2b8
Zhang08 method. 2.5 of 4 steps implemented.
LudmilaKrejcova Feb 16, 2025
ee51891
Yu21 now matches the provided source code
LudmilaKrejcova Feb 25, 2025
2a11521
Removed unnecessary parts, improved clarity.
LudmilaKrejcova Feb 27, 2025
aa897b8
Zhang08 is now working nearly as expected.
LudmilaKrejcova Mar 3, 2025
8518a41
Init method Hafner16
LudmilaKrejcova Mar 12, 2025
75a5780
Method works in most cases
LudmilaKrejcova Mar 18, 2025
b815f8c
Works, but it is slow
LudmilaKrejcova Mar 25, 2025
170b0a2
Fortmat
LudmilaKrejcova Apr 2, 2025
dfc6453
Refactoring
LudmilaKrejcova Apr 2, 2025
dc4388e
Format
LudmilaKrejcova Apr 6, 2025
3e44a86
Deleted unused commented-out code
LudmilaKrejcova Apr 6, 2025
4d0b76a
Add support for 0-255 input values
LudmilaKrejcova Apr 7, 2025
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
test
test
/.vscode
*.dot
/html
/latex
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ endif(DOXYGEN_FOUND)
add_subdirectory(tmolib/)
add_subdirectory(TMOgui/)
add_subdirectory(TMOCmd/)
add_subdirectory(TMOWard94/)
add_subdirectory(TMOZhao10/)

#add_subdirectory(TMOWard94/)
#add_subdirectory(TMOZhao10/)
#add_subdirectory(TMOMM16/) #Martin Molek
#add_subdirectory(TMOAlsam06/) #Jiri Zverina
add_subdirectory(TMOAlsam09/) #Martin Molek
add_subdirectory(TMOAncuti16/) #Vladimir Vlkovic
#add_subdirectory(TMOAlsam09/) #Martin Molek
#add_subdirectory(TMOAncuti16/) #Vladimir Vlkovic
#add_subdirectory(TMOCheryl11/) #Vaclav Chvila
#add_subdirectory(TMOFarbman08/) #Tomas Hudziec
add_subdirectory(TMOAubry14/) #Tomas Hudziec
add_subdirectory(TMOKou15/) #Tomas Hudziec
add_subdirectory(TMOMeylan06/)
add_subdirectory(TMODrago03/) #David Chocholaty
add_subdirectory(TMOParis11/) #David Chocholaty
add_subdirectory(TMOGastal11/) #David Chocholaty
add_subdirectory(TMOShan10/) #David Chocholaty
#add_subdirectory(TMOAubry14/) #Tomas Hudziec
#add_subdirectory(TMOKou15/) #Tomas Hudziec
#add_subdirectory(TMOMeylan06/)
#add_subdirectory(TMODrago03/) #David Chocholaty
#add_subdirectory(TMOParis11/) #David Chocholaty
#add_subdirectory(TMOGastal11/) #David Chocholaty
#add_subdirectory(TMOShan10/) #David Chocholaty
#add_subdirectory(TMOXia18/) #David Chocholaty
add_subdirectory(TMOYee03/) #Matus Bicanovsky
add_subdirectory(TMOChen05/) #Matus Bicanovsky
Expand All @@ -52,27 +53,31 @@ add_subdirectory(TMOLiu17/) #Peter Zdravecký
add_subdirectory(TMOLiu16/) #Jakub Krystufek
#add_subdirectory(TMOYourOperatorNameLinux/)
#add_subdirectory(TMOJin14/) #
add_subdirectory(TMOLee10/) #Martin Molek
add_subdirectory(TMOKim09/) #Petr Pospisil: method 1/Vladimir Vlkovic
add_subdirectory(TMOZheng15/) #Petr Pospisil: method 2
#add_subdirectory(TMOLee10/) #Martin Molek
#add_subdirectory(TMOKim09/) #Petr Pospisil: method 1/Vladimir Vlkovic
#add_subdirectory(TMOZheng15/) #Petr Pospisil: method 2
#add_subdirectory(TMOBae06/) #Petr Pospisil: method 3 (problem with gui, gui doesnt support TMOString parameter)
add_subdirectory(TMOBiswas05/) #Tomas Chlubna
#add_subdirectory(TMOBiswas05/) #Tomas Chlubna
#add_subdirectory(TMOCadik08/) #Martin Cadik/Jan Brida: OpenCL implementation (CPU and GPU versions)
add_subdirectory(TMOXiong17/) #Filip Brezna: method 1
add_subdirectory(TMOZhongping15/) #Filip Brezna: method 2
#add_subdirectory(TMOXiong17/) #Filip Brezna: method 1
#add_subdirectory(TMOZhongping15/) #Filip Brezna: method 2
#add_subdirectory(TMOJin17/) #Filip Brezna: method 3
#add_subdirectory(TMOHu14/) #Vladimir Vlkovic
#add_subdirectory(TMOTao17/) #Vladimir Vlkovic not ready
#add_subdirectory(TMOSon14/) #Sedlar Pavel, Tomas Hudziec
add_subdirectory(TMOCLAHE/) #Sedlar Pavel
#add_subdirectory(TMOCLAHE/) #Sedlar Pavel
#add_subdirectory(TMOKuhn08/) #Pavel Melcer
add_subdirectory(TMOEisemann04/) #Roman Jaska
add_subdirectory(TMOTai08/) #Michal Vlnas
#add_subdirectory(TMOEisemann04/) #Roman Jaska
#add_subdirectory(TMOTai08/) #Michal Vlnas
#add_subdirectory(TMONguy15/) #Matej Valek
add_subdirectory(TMOWu24/) #Filip Sapak
add_subdirectory(TMOWu24_2/) #Branislav Dubec
add_subdirectory(TMONafchi17) #Tomas Krivanek
add_subdirectory(TMONafchi17_2/) #Boris Strbak
#add_subdirectory(TMOWu24/) #Filip Sapak
#add_subdirectory(TMOWu24_2/) #Branislav Dubec
#add_subdirectory(TMONafchi17) #Tomas Krivanek
#add_subdirectory(TMONafchi17_2/) #Boris Strbak
add_subdirectory(TMOAmbalathankandy21/) #Ludmila Krejcova
add_subdirectory(TMOYu21/) #Ludmila Krejcova
add_subdirectory(TMOZhang08/) #Ludmila Krejcova
add_subdirectory(TMOHafner16/) #Ludmila Krejcova

INSTALL(FILES tmolib/libtmo.so DESTINATION lib)
INSTALL(FILES TMOgui/tmogui PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION . )
Expand Down
37 changes: 37 additions & 0 deletions TMOAmbalathankandy21/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")

IF(UNIX AND NOT LINUX_SET)
ADD_DEFINITIONS(-D LINUX)
ENDIF(UNIX AND NOT LINUX_SET)

INCLUDE_DIRECTORIES(
../tmolib/
.
)

LINK_LIBRARIES (
tmo
)

SET(SOURCES
TMOAmbalathankandy21.cpp
TMOPlugin.cpp
)


SET(HEADERS
TMOAmbalathankandy21.h
TMOPlugin.h
)

add_library( Ambalathankandy21 SHARED ${SOURCES} ${HEADERS})
add_custom_command( TARGET Ambalathankandy21 POST_BUILD
COMMAND cp -f libAmbalathankandy21.so ../TMOCmd/Ambalathankandy21.tml
COMMAND cp -f libAmbalathankandy21.so ../TMOgui/Ambalathankandy21.tml
COMMAND cp -f libAmbalathankandy21.so ../Ambalathankandy21.tml
# COMMAND rm -f libqueiroz06.so
)
133 changes: 133 additions & 0 deletions TMOAmbalathankandy21/TMOAmbalathankandy21.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*******************************************************************************
* *
* Brno University of Technology *
* Faculty of Information Technology *
* *
* Color-to-Grayscale Conversions *
* *
* Author: Ludmila Krejcova [xkrejc85 AT stud.fit.vutbr.cz] *
* Brno 2025 *
* *
* Implementation of the TMOAmbalathankandy21 class *
* *
* A color temperature-based high-speed decolorization: *
* an empirical approach for tone mapping applications *
* https://doi.org/10.48550/arXiv.2108.13656 *
* *
*******************************************************************************/

#include "TMOAmbalathankandy21.h"

TMOAmbalathankandy21::TMOAmbalathankandy21()
{
SetName(L"Ambalathankandy21");
SetDescription(L"A color temperature-based high-speed decolorization");
}

TMOAmbalathankandy21::~TMOAmbalathankandy21()
{
}

// Computes the minimum and maximum values in the image for normalization
std::pair<double, double> TMOAmbalathankandy21::getImageMinMax(TMOImage &image)
{
double min(std::numeric_limits<double>::max());
double max(-max);

auto data = image.GetData();
for(size_t i = 0; i < 3 * image.GetWidth() * image.GetHeight(); ++i)
{
double value = *data++;
min = std::min(min, value);
max = std::max(max, value);
}

return std::make_pair(min, max);
}

// Normalizes the grayscale image (not part of the original article, added for comparison)
void TMOAmbalathankandy21::normalizeGrayscaleImage(TMOImage &image)
{
auto minmax = getImageMinMax(image);

double min(minmax.first);
double max(minmax.second);

if(max > min)
{
auto data = image.GetData();
double invRange(1.0 / (max - min));

for(size_t i = 0; i < 3 * image.GetWidth() * image.GetHeight(); ++i)
{
*data++ = (*data - min) * invRange;
}
}
}

// Finds if range is 0-1 or in 0-255
bool TMOAmbalathankandy21::isInRange0to1(double *pSourceData, int numPix)
{
for (int i = 0; i < numPix * 3; i++)
{
if(pSourceData[i] > 1)
return false;
}
return true;
}


/* --------------------------------------------------------------------------- *
* Applies the tone mapping operator to transform the image. *
* --------------------------------------------------------------------------- */
int TMOAmbalathankandy21::Transform()
{
double *pSourceData = pSrc->GetData();
double *pDestinationData = pDst->GetData();

double R, G, B, L_White, L_RG, L_Warm, L_Cool, L_B, L;

// Constants based on the reference article
double betaR = 0.55;
double betaK = 0.7;

bool range0to1 = isInRange0to1(pSourceData, pSrc->GetHeight() * pSrc->GetWidth());

// Iterate over each pixel in the image
for (int j = 0; j < pSrc->GetHeight(); j++)
{
pSrc->ProgressBar(j, pSrc->GetHeight()); // Progress bar
for (int i = 0; i < pSrc->GetWidth(); i++)
{
// Read RGB values from the input image
R = *pSourceData++;
G = *pSourceData++;
B = *pSourceData++;

// If format is in range 0-255
if (!range0to1)
{
R /= 255;
G /= 255;
B /= 255;
}

// Compute luminance components
L_White = sqrt((R*R + G*G + B*B)/3);
L_B = B;
L_RG = sqrt(betaR * R * R + (1 - betaR) * G * G);
L_Warm = R / (R + G + B)*L_RG + (1 - R / (R + G + B)) * L_White;
L_Cool = (1 - B / (R + G + B))*L_B + B/(R + G + B) * L_White;
L = sqrt(betaK *L_Warm * L_Warm + (1 - betaK) * L_Cool * L_Cool);

// Store the computed luminance as grayscale output
*pDestinationData++ = L;
*pDestinationData++ = L;
*pDestinationData++ = L;
}
}

// Optional: Normalize the output image (not part of the original article)
normalizeGrayscaleImage(*pDst);
return 0;
}
42 changes: 42 additions & 0 deletions TMOAmbalathankandy21/TMOAmbalathankandy21.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* *
* Brno University of Technology *
* Faculty of Information Technology *
* *
* Color-to-Grayscale Conversions *
* *
* Author: Ludmila Krejcova [xkrejc85 AT stud.fit.vutbr.cz] *
* Brno 2025 *
* *
* Implementation of the TMOAmbalathankandy21 class *
* *
* A color temperature-based high-speed decolorization: *
* an empirical approach for tone mapping applications *
* https://doi.org/10.48550/arXiv.2108.13656 *
* *
*******************************************************************************/


#include <TMO.h>

class TMOAmbalathankandy21 : public TMO
{
public:
TMOAmbalathankandy21();


virtual ~TMOAmbalathankandy21();
virtual int Transform() override;

// Normalizes the grayscale image (not part of the original article, added for compariso
void normalizeGrayscaleImage(TMOImage &image);

// Computes the minimum and maximum values in the image for normalization
std::pair<double, double> getImageMinMax(TMOImage &image);

// Finds if range is 0-1 or in 0-255
bool isInRange0to1(double *pSourceData, int numPix);

protected:
TMODouble dParameter;
};
80 changes: 80 additions & 0 deletions TMOAmbalathankandy21/TMOPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* -------------------------------------------------------------------- *
* TMOPlugin.cpp : Template for tone mapping operator plugin *
* in Tone Mapping Studio 2004 *
* -------------------------------------------------------------------- *
* *
* Put this file into a DLL project with your plugin functions and *
* replace commented sections below. *
* *
* Add this preprocesor definition to the project setings : *
* *
* TMOPLUGIN_EXPORTS *
* *
* -------------------------------------------------------------------- */
#include "./TMOPlugin.h"

/* -------------------------------------------------------------------- *
* Insert your operator header below *
* -------------------------------------------------------------------- */
#include "./TMOAmbalathankandy21.h"

/* -------------------------------------------------------------------- *
* Insert a number of implemented operators *
* -------------------------------------------------------------------- */
int iOperatorCount = 1;

/* -------------------------------------------------------------------- *
* DLL Entry point; no changes necessary *
* -------------------------------------------------------------------- */
/*
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
*/
/* -------------------------------------------------------------------- *
* Returns a number of implemented operators; no changes necessary *
* -------------------------------------------------------------------- */
int TMOPLUGIN_API OperatorCount()
{
return iOperatorCount;
}

/* -------------------------------------------------------------------- *
* For each implemented operator create a new object in field operators,*
* then return number of created operators *
* For exemple : *
* *
* operators[0] = new TMOOperator1; *
* operators[1] = new TMOOperator2; *
* . *
* . *
* . *
* -------------------------------------------------------------------- */
int TMOPLUGIN_API EnumOperators(TMO **operators)
{
operators[0] = new TMOAmbalathankandy21;
return iOperatorCount;
}

/* -------------------------------------------------------------------- *
* Deletes operators; no changes necessary *
* -------------------------------------------------------------------- */
int TMOPLUGIN_API DeleteOperators(TMO **operators)
{
int i;
for (i = 0; i < iOperatorCount; i++)
delete operators[i];
return iOperatorCount;
}
Loading