App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
app::TLUTGenerator< TPIXEL, TCHANNEL > Class Template Reference

`#include <TLUTGenerator.hpp>`

## Public Member Functions
| TLUTGenerator ()
virtual | ~TLUTGenerator ()
int | fillBrightnessLUT_4ch (TLUT< TPIXEL, TCHANNEL > &dst, double bias)
int | fillContrastLUT_4ch (TLUT< TPIXEL, TCHANNEL > &dst, double bias)
int | fillGammaLUT_4ch (TLUT< TPIXEL, TCHANNEL > &dst, double gamma)
int | fillCurvesLUT_4ch (TLUT< TPIXEL, TCHANNEL > &dst, double *xM, double *yM, unsigned cM, double *xR, double *yR, unsigned cR, double *xG, double *yG, unsigned cG, double *xB, double *yB, unsigned cB, double *xA, double *yA, unsigned cA)
virtual TLUT< TPIXEL, TCHANNEL > * | createBrightnessLUT_4ch (double bias)
virtual TLUT< TPIXEL, TCHANNEL > * | createContrastLUT_4ch (double bias)
virtual TLUT< TPIXEL, TCHANNEL > * | createGammaLUT_4ch (double gamma)
virtual TLUT< TPIXEL, TCHANNEL > * | createCurvesLUT_4ch (double *xM, double *yM, unsigned cM, double *xR, double *yR, unsigned cR, double *xG, double *yG, unsigned cG, double *xB, double *yB, unsigned cB, double *xA, double *yA, unsigned cA)

## Static Public Attributes
static const TCHANNEL | maxVal = ~0
| Maximální hodnota kanálu.
static const TCHANNEL | halfVal = maxVal / 2
| Polovina maximální hodnoty kanálu.
static const unsigned | chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
| Počet kanálů bitmapy.

## Protected Member Functions
virtual int | prepareChannelLUT (TCHANNEL *ch, CubicSpline *sp)
| Předpočítá LUT pro daný kanál.
virtual int | prepareChannelLUT (TCHANNEL *ch, CubicSpline *sp1, CubicSpline *sp2)
| Předpočítá LUT pro daný kanál.

## Detailed Description

### template<typename TPIXEL, typename TCHANNEL>
class app::TLUTGenerator< TPIXEL, TCHANNEL >

Definition at line 20 of file TLUTGenerator.hpp.

## Constructor & Destructor Documentation

template<typename TPIXEL, typename TCHANNEL>

app::TLUTGenerator< TPIXEL, TCHANNEL >::TLUTGenerator | ( |  | ) |
| inline

Definition at line 46 of file TLUTGenerator.hpp.

{}
template<typename TPIXEL , typename TCHANNEL >

TLUTGenerator< TPIXEL, TCHANNEL >::~TLUTGenerator | ( |  | ) |
| virtual

Definition at line 14 of file TLUTGenerator.cpp.

{
}

## Member Function Documentation

template<typename TPIXEL , typename TCHANNEL >

TLUT< TPIXEL, TCHANNEL > * TLUTGenerator< TPIXEL, TCHANNEL >::createBrightnessLUT_4ch | ( | double | bias | ) |
| virtual

Definition at line 175 of file TLUTGenerator.cpp.

{
TLUT<TPIXEL, TCHANNEL> * retVal = new TLUT<TPIXEL, TCHANNEL>();
if (retVal == NULL) {
return NULL;
}
if (!retVal->isInitOk()) {
delete retVal;
return NULL;
}
if (fillBrightnessLUT_4ch(*retVal, bias)) {
delete retVal;
return NULL;
}
return retVal;
}
template<typename TPIXEL , typename TCHANNEL >

TLUT< TPIXEL, TCHANNEL > * TLUTGenerator< TPIXEL, TCHANNEL >::createContrastLUT_4ch | ( | double | bias | ) |
| virtual

Definition at line 222 of file TLUTGenerator.cpp.

{
TLUT<TPIXEL, TCHANNEL> * retVal = new TLUT<TPIXEL, TCHANNEL>();
if (retVal == NULL) {
return NULL;
}
if (!retVal->isInitOk()) {
delete retVal;
return NULL;
}
if (fillContrastLUT_4ch(*retVal, bias)) {
delete retVal;
return NULL;
}
return retVal;
}
template<typename TPIXEL , typename TCHANNEL >

TLUT< TPIXEL, TCHANNEL > * TLUTGenerator< TPIXEL, TCHANNEL >::createCurvesLUT_4ch | ( | double * | xM,
|  | double * | yM,
|  | unsigned | cM,
|  | double * | xR,
|  | double * | yR,
|  | unsigned | cR,
|  | double * | xG,
|  | double * | yG,
|  | unsigned | cG,
|  | double * | xB,
|  | double * | yB,
|  | unsigned | cB,
|  | double * | xA,
|  | double * | yA,
|  | unsigned | cA
| ) |  |
| virtual

Definition at line 19 of file TLUTGenerator.cpp.

{
TLUT<TPIXEL, TCHANNEL> * retVal = new TLUT<TPIXEL, TCHANNEL>();
if (retVal == NULL) {
return NULL;
}
if (!retVal->isInitOk()) {
delete retVal;
return NULL;
}
if (fillCurvesLUT_4ch(*retVal, xM, yM, cM, xR, yR, cR, xG, yG, cG, xB, yB, cB, xA, yA, cA)) {
delete retVal;
return NULL;
}
return retVal;
}
template<typename TPIXEL , typename TCHANNEL >

TLUT< TPIXEL, TCHANNEL > * TLUTGenerator< TPIXEL, TCHANNEL >::createGammaLUT_4ch | ( | double | gamma | ) |
| virtual

Definition at line 273 of file TLUTGenerator.cpp.

{
TLUT<TPIXEL, TCHANNEL> * retVal = new TLUT<TPIXEL, TCHANNEL>();
if (retVal == NULL) {
return NULL;
}
if (!retVal->isInitOk()) {
delete retVal;
return NULL;
}
if (fillGammaLUT_4ch(*retVal, gamma)) {
delete retVal;
return NULL;
}
return retVal;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::fillBrightnessLUT_4ch | ( | TLUT< TPIXEL, TCHANNEL > & | dst,
|  | double | bias
| ) |  |

Definition at line 144 of file TLUTGenerator.cpp.

{
double factor = (bias < 0) ? 1 + bias : 1 - bias;
TCHANNEL offset = (bias < 0) ? 0 : bias * maxVal + 0.5;
if (!dst.isInitOk()) {
return 1;
}
TCHANNEL * lut = dst.getValues()[0];
TCHANNEL * lutEnd = lut + maxVal + 1;
long tmp;
int i = 0;
while (lut < lutEnd) {
*lut = factor * i + offset + 0.5;
i++;
// *lut = (tmp >= maxVal) ? maxVal : (tmp <= 0) ? 0 : tmp; // !!! Vždy by mělo být v této podobě ve správném rozsahu, takže pro optimalizaci by šla vynechat kontrola mezí...
lut++;
}
memcpy(dst.getValues()[1], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
memcpy(dst.getValues()[2], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
lut = dst.getValues()[3];
lutEnd = lut + maxVal + 1;
i = 0;
while (lut < lutEnd) {
*lut = i++;
lut++;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::fillContrastLUT_4ch | ( | TLUT< TPIXEL, TCHANNEL > & | dst,
|  | double | bias
| ) |  |

Definition at line 193 of file TLUTGenerator.cpp.

{
double factor = (bias + 1) / (1.0001 - bias);
if (!dst.isInitOk()) {
return 1;
}
TCHANNEL * lut = dst.getValues()[0];
TCHANNEL * lutEnd = lut + maxVal + 1;
long tmp;
int i = 0;
while (lut < lutEnd) {
tmp = factor * (i - halfVal) + halfVal + 0.5;
i++;
*lut = (tmp >= maxVal) ? maxVal : (tmp <= 0) ? 0 : tmp;
lut++;
}
memcpy(dst.getValues()[1], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
memcpy(dst.getValues()[2], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
lut = dst.getValues()[3];
lutEnd = lut + maxVal + 1;
i = 0;
while (lut < lutEnd) {
*lut = i++;
lut++;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::fillCurvesLUT_4ch | ( | TLUT< TPIXEL, TCHANNEL > & | dst,
|  | double * | xM,
|  | double * | yM,
|  | unsigned | cM,
|  | double * | xR,
|  | double * | yR,
|  | unsigned | cR,
|  | double * | xG,
|  | double * | yG,
|  | unsigned | cG,
|  | double * | xB,
|  | double * | yB,
|  | unsigned | cB,
|  | double * | xA,
|  | double * | yA,
|  | unsigned | cA
| ) |  |

Definition at line 42 of file TLUTGenerator.cpp.

{
if (!dst.isInitOk()) {
return 1;
}
CubicSpline * splines[] = {NULL, NULL, NULL, NULL, NULL};
int initiOk = 1;
if (xM != NULL && yM != NULL && initiOk) {
splines[0] = new CubicSpline(xM, yM, cM);
if (splines[0] == NULL) {
initiOk = 0;
}
}
if (xR != NULL && yR != NULL && initiOk) {
splines[1] = new CubicSpline(xR, yR, cR);
if (splines[1] == NULL) {
initiOk = 0;
}
}
if (xG != NULL && yG != NULL && initiOk) {
splines[2] = new CubicSpline(xG, yG, cG);
if (splines[2] == NULL) {
initiOk = 0;
}
}
if (xB != NULL && yB != NULL && initiOk) {
splines[3] = new CubicSpline(xB, yB, cB);
if (splines[3] == NULL) {
initiOk = 0;
}
}
if (xA != NULL && yA != NULL && initiOk) {
splines[4] = new CubicSpline(xA, yA, cA);
if (splines[3] == NULL) {
initiOk = 0;
}
}
if (initiOk) {
for (int i = 0; i < 3; i++) {
prepareChannelLUT(dst.getValues()[i], splines[0], splines[i + 1]);
}
prepareChannelLUT(dst.getValues()[3], splines[4]);
}
for (int i = 0; i < 5; i++) {
if (splines[i] != NULL) {
delete splines[i];
}
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::fillGammaLUT_4ch | ( | TLUT< TPIXEL, TCHANNEL > & | dst,
|  | double | gamma
| ) |  |

Definition at line 239 of file TLUTGenerator.cpp.

{
if (gamma < 0.00001) {
gamma = 0.00001;
} else if (gamma > 100) {
gamma = 100;
}
if (!dst.isInitOk()) {
return 1;
}
TCHANNEL * lut = dst.getValues()[0];
TCHANNEL * lutEnd = lut + maxVal + 1;
long tmp;
double val = 0;
double delta = 1.0 / maxVal;
while (lut < lutEnd) {
*lut = maxVal * (pow(val, gamma)) + 0.5;
val += delta;
// *lut = (tmp >= maxVal) ? maxVal : (tmp <= 0) ? 0 : tmp; // Clamping pravdepodobne neni nutny...
lut++;
}
memcpy(dst.getValues()[1], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
memcpy(dst.getValues()[2], dst.getValues()[0], (maxVal + 1) * sizeof(TCHANNEL));
lut = dst.getValues()[3];
lutEnd = lut + maxVal + 1;
int i = 0;
while (lut < lutEnd) {
*lut = i++;
lut++;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::prepareChannelLUT | ( | TCHANNEL * | ch,
|  | CubicSpline * | sp
| ) |  |
| protectedvirtual

Předpočítá LUT pro daný kanál.

Předpočítá LUT pro daný kanál na základě funkce určené kubickým splajnem.

Parameters

  ch | Ukazatel na počátek dat v LUT
  sp | Ukazatel na kubický spline, který udává převodní funkci, pokud je NULL nahradí se identitou

Returns
  Vrací 0 při úspěchu, jinak kód chyby.

Definition at line 103 of file TLUTGenerator.cpp.

{
if (ch == NULL) { return 1; }
TCHANNEL * chEnd = ch + maxVal + 1;
if (sp == NULL) {
int i = 0;
while (ch < chEnd) {
*ch = i++;
ch++;
}
return 0;
}
long tmp;
double x = 0;
double dx = 1 / (double) maxVal;
while (ch < chEnd) {
tmp = sp->getValueAt(x) * maxVal + 0.5;
*ch = (tmp >= maxVal) ? maxVal : (tmp <= 0) ? 0 : tmp; // !!! Vždy by mělo být v této podobě ve správném rozsahu, takže pro optimalizaci by šla vynechat kontrola mezí...
ch++; x += dx;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUTGenerator< TPIXEL, TCHANNEL >::prepareChannelLUT | ( | TCHANNEL * | ch,
|  | CubicSpline * | sp1,
|  | CubicSpline * | sp2
| ) |  |
| protectedvirtual

Předpočítá LUT pro daný kanál.

Předpočítá LUT pro daný kanál na základě funkce určené kubickými splajny. Výsledná funkce v x se urší jako sp1(sp2(x))

Parameters

  ch | Ukazatel na počátek dat v LUT
  sp1 | Ukazatel na kubický spline, který udává převodní funkci, pokud je NULL nahradí se identitou
  sp2 | Ukazatel na kubický spline, který udává převodní funkci, pokud je NULL nahradí se identitou

Returns
  Vrací 0 při úspěchu, jinak kód chyby.

Definition at line 126 of file TLUTGenerator.cpp.

{
if (ch == NULL) { return 1; }
if (sp1 == NULL) { return prepareChannelLUT(ch, sp2); }
if (sp2 == NULL) { return prepareChannelLUT(ch, sp1); }
TCHANNEL * chEnd = ch + maxVal + 1;
long tmp;
double x = 0;
double dx = 1 / (double) maxVal;
while (ch < chEnd) {
tmp = sp1->getValueAt(sp2->getValueAt(x)) * maxVal + 0.5; // V tomhle pořadí aplikuje operace GIMP
*ch = (tmp >= maxVal) ? maxVal : (tmp <= 0) ? 0 : tmp; // !!! Vždy by mělo být v této podobě ve správném rozsahu, takže pro optimalizaci by šla vynechat kontrola mezí...
ch++; x += dx;
}
return 0;
}

## Member Data Documentation

template<typename TPIXEL, typename TCHANNEL>

const unsigned TLUTGenerator< TPIXEL, TCHANNEL >::chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
| static

Počet kanálů bitmapy.

Definition at line 44 of file TLUTGenerator.hpp.

template<typename TPIXEL, typename TCHANNEL>

const TCHANNEL TLUTGenerator< TPIXEL, TCHANNEL >::halfVal = maxVal / 2
| static

Polovina maximální hodnoty kanálu.

Definition at line 43 of file TLUTGenerator.hpp.

template<typename TPIXEL, typename TCHANNEL>

const TCHANNEL TLUTGenerator< TPIXEL, TCHANNEL >::maxVal = ~0
| static

Maximální hodnota kanálu.

Definition at line 42 of file TLUTGenerator.hpp.

The documentation for this class was generated from the following files:

- /home/xxx/eclipse_workspaces/app/appcore/jni/app/pointops_new/TLUTGenerator.hpp
- /home/xxx/eclipse_workspaces/app/appcore/jni/app/pointops_new/TLUTGenerator.cpp