App

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

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

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

Třída pro filtr Gaussovského rozsostření. More...

`#include <TGaussianBlur.hpp>`

Inheritance diagram for app::TGaussianBlur< TPIXEL, TCHANNEL >:

## Public Member Functions
| TGaussianBlur (double xSigma=0.35, double ySigma=0.35)
| Konstruktor.
virtual | ~TGaussianBlur ()
| Destruktor.
virtual int | isInitOk ()
virtual int | applyTo (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstRect)
virtual int | applyTo (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstRect, double alpha)
virtual int | applyTo (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig)
virtual int | applyTo (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig, double alpha)

## Protected Member Functions
virtual int | applyTo_1ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstArea)
virtual int | applyTo_1ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstRect, double alpha)
virtual int | applyTo_1ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig)
virtual int | applyTo_1ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig, double alpha)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstRect)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, Rect dstRect, double alpha)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &bitmap, TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig, double alpha)

## Protected Attributes
double * | xKernel
| Jádro použité v prvním průchodu - horizontální směr.
int | xKernelWidth
| Šířka horizontálního jádra.
int | xKernelCenter
| Souřadnice prvku přesně uprostřed horizontálního jádra.
double * | yKernel
| Jádro použité v druhém průchodu - vertikální směr.
int | yKernelWidth
| Šířka vertikálního jádra.
int | yKernelCenter
| Souřadnice prvku přesně uprostřed vertikálního jádra.

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

## Detailed Description

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

Třída pro filtr Gaussovského rozsostření.

Třída pro filtr Gaussovského rozsostření. Gaussovské rozostření je aplikováno nezávisle ve dvou osách. Využívá separability filtru.

Definition at line 31 of file TGaussianBlur.hpp.

## Constructor & Destructor Documentation

template<typename TPIXEL, typename TCHANNEL>

app::TGaussianBlur< TPIXEL, TCHANNEL >::TGaussianBlur | ( | double | xSigma = `0.35`,
|  | double | ySigma = `0.35`
| ) |  |
| inline

Konstruktor.

Vytvoří Gaussovské rozostřeni, s nezávislým rozptylem ve dvou osách, minimální hodnota rozptylu v každé ose je 0.35

Nepoužívá normalizovanou verzi Gausse, protože je stejně nutné koeficienty nakonec přepočítat tak, aby jejich součet byl roven 1.

Parameters

  xSigma | Horizontální rozptyl.
  ySigma | Vertikální rozptyl.

Definition at line 44 of file TGaussianBlur.hpp.

{
if (xSigma < 0 || ySigma < 0) { return; }
xSigma = (xSigma < 0.1) ? 0.1 : xSigma;
ySigma = (ySigma < 0.1) ? 0.1 : ySigma;
this->xKernelCenter = 3 * xSigma; // Muze byt 0
this->xKernelWidth = 2 * this->xKernelCenter + 1; // minim. 1
this->xKernel = (double *) malloc(this->xKernelWidth * sizeof(double));
if (this->xKernel == NULL) { return; }
double xSigma2 = xSigma * xSigma;
double r = 0;
double factor = 0;
for (int i = 0; i < this->xKernelWidth; ++i) {
r = this->xKernelCenter - i;
this->xKernel[i] = exp(-0.5 * (r * r) / xSigma2);
factor += this->xKernel[i];
}
for (int i = 0; i < this->xKernelWidth; ++i) {
this->xKernel[i] /= factor;
}
this->yKernelCenter = 3 * ySigma;
this->yKernelWidth = 2 * this->yKernelCenter + 1;
this->yKernel = (double *) malloc(this->yKernelWidth * sizeof(double));
if (this->yKernel == NULL) { free(this->xKernel); this->xKernel = NULL; return; }
double ySigma2 = ySigma * ySigma;
factor = 0;
for (int i = 0; i < this->yKernelWidth; ++i) {
r = this->yKernelCenter - i;
this->yKernel[i] = exp(-0.5 * (r * r) / ySigma2);
factor += this->yKernel[i];
}
for (int i = 0; i < this->yKernelWidth; ++i) {
this->yKernel[i] /= factor;
}
}
template<typename TPIXEL , typename TCHANNEL >

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

Destruktor.

Definition at line 15 of file TGaussianBlur.cpp.

{}

## Member Function Documentation

template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstRect
| ) |  |
| virtualinherited

Definition at line 52 of file TFilter.cpp.

{
if (chCount == 1) {
return applyTo_1ch(bitmap, dstRect);
} else if (chCount == 4) {
return applyTo_4ch(bitmap, dstRect);
} else {
return 888;
}
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstRect,
|  | double | alpha
| ) |  |
| virtualinherited

Definition at line 62 of file TFilter.cpp.

{
if (chCount == 1) {
return applyTo_1ch(bitmap, dstRect, alpha);
} else if (chCount == 4) {
return applyTo_4ch(bitmap, dstRect, alpha);
} else {
return 888;
}
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig
| ) |  |
| virtualinherited

Definition at line 72 of file TFilter.cpp.

{
if (chCount == 1) {
return applyTo_1ch(bitmap, msk, mskRect, mskOrig);
} else if (chCount == 4) {
return applyTo_4ch(bitmap, msk, mskRect, mskOrig);
} else {
return 888;
}
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig,
|  | double | alpha
| ) |  |
| virtualinherited

Definition at line 82 of file TFilter.cpp.

{
if (chCount == 1) {
return applyTo_1ch(bitmap, msk, mskRect, mskOrig, alpha);
} else if (chCount == 4) {
return applyTo_4ch(bitmap, msk, mskRect, mskOrig, alpha);
} else {
return 888;
}
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo_1ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstRect,
|  | double | alpha
| ) |  |
| protectedvirtualinherited

Definition at line 22 of file TFilter.cpp.

{
return 999;
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo_1ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig
| ) |  |
| protectedvirtualinherited

Definition at line 26 of file TFilter.cpp.

{
return 999;
}
template<typename TPIXEL , typename TCHANNEL >

int TFilter< TPIXEL, TCHANNEL >::applyTo_1ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig,
|  | double | alpha
| ) |  |
| protectedvirtualinherited

Definition at line 30 of file TFilter.cpp.

{
return 999;
}
template<typename TPIXEL , typename TCHANNEL >

int TSeparableFilter< TPIXEL, TCHANNEL >::applyTo_1ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstArea
| ) |  |
| protectedvirtualinherited

Reimplemented from app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 135 of file TSeparableFilter.cpp.

{
if (this->chCount != 1) {
return 1;
}
if (xKernel == NULL || yKernel == NULL) { // Kontrola 1 vlastne neni potreba
return 2;
}
TPIXEL * const srcData = bitmap.getData();
if (srcData == NULL) {
return 3;
}
unsigned origWidth = bitmap.getWidth();
unsigned origHeight = bitmap.getHeight();
unsigned tmpWidth = origHeight;
unsigned tmpHeight = origWidth;
TPIXEL * const tmpData = (TPIXEL *) malloc(tmpWidth * tmpHeight * sizeof(TPIXEL));
if (tmpData == NULL) {
delete tmpData;
return 4;
}
Rect crop = Rect::getIntersection(srcRect, bitmap.getRect());
int wasOk = 0;
{
/* JMENNÉ KONVENCE PRO PROMĚNNÉ FILTRU.
TPIXEL * src, *dst;
TCHANNEL * msk;
double alpha;
int srcWidth, srcHeight;
int dstWidth, dstHeight;
int mskWidth, mskHeight;
int xSrcMin, xSrcMax, ySrcMin, ySrcMax;
int xDstMin, xDstMax, yDstMin, yDstMax;
int xMskMin, xMskMax, yMskMin, yMskMax;
double * kernel;
int kernelCenter;
int kernelWidth;
*/
TPIXEL * src = srcData;
int srcWidth = origWidth;
int xSrcMin = crop.tl.x;
int xSrcMax = crop.br.x;
int ySrcMin = crop.tl.y - yKernelCenter;
ySrcMin = (ySrcMin < 0) ? 0 : ySrcMin;
int ySrcMax = crop.br.y + yKernelCenter;
ySrcMax = (ySrcMax > origHeight) ? origHeight : ySrcMax;
TPIXEL * dst = tmpData;
int dstWidth = tmpWidth;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
int xDstMin = ySrcMin;
int yDstMin = xSrcMin;
double * kernel = xKernel;
int kernelCenter = xKernelCenter;
int kernelWidth = xKernelWidth;
double sum;
SEPARABLE_FILTER_ALGORITHM_GENERAL(dPtr = dPtrColBgn++;, sum = 0;, sum += *sTmpPtr * *kernelPtr;, *dPtr = sum + 0.5;, dPtr += dstWidth;)
wasOk = initOk;
}
if (wasOk) {
TPIXEL * src = tmpData;
int srcWidth = tmpWidth;
int xSrcMin = crop.tl.y;
int xSrcMax = crop.br.y;
int ySrcMin = crop.tl.x;
int ySrcMax = crop.br.x;
TPIXEL * dst = srcData;
int dstWidth = origWidth;
int xDstMin = crop.tl.x;
int yDstMin = crop.tl.y;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
double * kernel = yKernel;
int kernelCenter = yKernelCenter;
int kernelWidth = yKernelWidth;
double sum;
SEPARABLE_FILTER_ALGORITHM_GENERAL(dPtr = dPtrColBgn++;, sum = 0;, sum += *sTmpPtr * *kernelPtr;, *dPtr = sum + 0.5;, dPtr += dstWidth;)
}
free(tmpData);
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TSeparableFilter< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstRect
| ) |  |
| protectedvirtualinherited

Reimplemented from app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 249 of file TSeparableFilter.cpp.

{
if (this->chCount != 4) {
return 1;
}
if (xKernel == NULL || yKernel == NULL) {
return 2;
} // pro mensi nez 2 se nepodari vytvorit reindexer, zkolabuje, navic je cely nesmysl - bodova operace v danem smeru
TPIXEL * const srcData = bitmap.getData();
if (srcData == NULL) {
return 3;
}
unsigned origWidth = bitmap.getWidth();
unsigned origHeight = bitmap.getHeight();
unsigned tmpWidth = origHeight;
unsigned tmpHeight = origWidth;
TPIXEL * const tmpData = (TPIXEL *) malloc(tmpWidth * tmpHeight * sizeof(TPIXEL)); // Dočasná bitmapa, do které se provede filtr dle řádků a ze které se filtruje dle sloupců do původní bitmapy.
if (tmpData == NULL) {
delete tmpData;
return 4;
}
Rect crop = Rect::getIntersection(srcRect, bitmap.getRect());
int wasOk = 0;
{
TPIXEL * src = srcData;
int srcWidth = origWidth;
int xSrcMin = crop.tl.x;
int xSrcMax = crop.br.x;
int ySrcMin = crop.tl.y - yKernelCenter;
ySrcMin = (ySrcMin < 0) ? 0 : ySrcMin;
int ySrcMax = crop.br.y + yKernelCenter;
ySrcMax = (ySrcMax > origHeight) ? origHeight : ySrcMax;
TPIXEL * dst = tmpData;
int dstWidth = tmpWidth;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
int xDstMin = ySrcMin;
int yDstMin = xSrcMin;
double * kernel = xKernel;
int kernelCenter = xKernelCenter;
int kernelWidth = xKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
*chPtr = sumR / (sumA) + 0.5; chPtr++;
*chPtr = sumG / (sumA) + 0.5; chPtr++;
*chPtr = sumB / (sumA) + 0.5; chPtr++;
*chPtr = sumA + 0.5;,
dPtr += dstWidth;
)
wasOk = initOk; // Pokud ne, v tmp jsou nahodna data.
}
if (wasOk) {
TPIXEL * src = tmpData;
int srcWidth = tmpWidth;
int xSrcMin = crop.tl.y;
int xSrcMax = crop.br.y;
int ySrcMin = crop.tl.x;
int ySrcMax = crop.br.x;
TPIXEL * dst = srcData;
int dstWidth = origWidth;
int xDstMin = crop.tl.x;
int yDstMin = crop.tl.y;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
double * kernel = yKernel;
int kernelCenter = yKernelCenter;
int kernelWidth = yKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
*chPtr = sumR / (sumA) + 0.5; chPtr++;
*chPtr = sumG / (sumA) + 0.5; chPtr++;
*chPtr = sumB / (sumA) + 0.5; chPtr++;
*chPtr = sumA + 0.5;,
dPtr += dstWidth;
)
}
free(tmpData);
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TSeparableFilter< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | Rect | dstRect,
|  | double | alpha
| ) |  |
| protectedvirtualinherited

Reimplemented from app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 400 of file TSeparableFilter.cpp.

{
if (this->chCount != 4) {
return 1;
}
if (xKernel == NULL || yKernel == NULL) {
return 2;
} // pro mensi nez 2 se nepodari vytvorit reindexer, zkolabuje, navic je cely nesmysl - bodova operace v danem smeru
TPIXEL * const srcData = bitmap.getData();
if (srcData == NULL) {
return 3;
}
unsigned origWidth = bitmap.getWidth();
unsigned origHeight = bitmap.getHeight();
unsigned tmpWidth = origHeight;
unsigned tmpHeight = origWidth;
TPIXEL * const tmpData = (TPIXEL *) malloc(tmpWidth * tmpHeight * sizeof(TPIXEL)); // Dočasná bitmapa, do které se provede filtr dle řádků a ze které se filtruje dle sloupců do původní bitmapy.
if (tmpData == NULL) {
delete tmpData;
return 4;
}
Rect crop = Rect::getIntersection(srcRect, bitmap.getRect());
int wasOk = 0;
{
TPIXEL * src = srcData;
int srcWidth = origWidth;
int xSrcMin = crop.tl.x;
int xSrcMax = crop.br.x;
int ySrcMin = crop.tl.y - yKernelCenter;
ySrcMin = (ySrcMin < 0) ? 0 : ySrcMin;
int ySrcMax = crop.br.y + yKernelCenter;
ySrcMax = (ySrcMax > origHeight) ? origHeight : ySrcMax;
TPIXEL * dst = tmpData;
int dstWidth = tmpWidth;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
int xDstMin = ySrcMin;
int yDstMin = xSrcMin;
double * kernel = xKernel;
int kernelCenter = xKernelCenter;
int kernelWidth = xKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
*chPtr = sumR / (sumA) + 0.5; chPtr++;
*chPtr = sumG / (sumA) + 0.5; chPtr++;
*chPtr = sumB / (sumA) + 0.5; chPtr++;
*chPtr = sumA + 0.5;,
dPtr += dstWidth;
)
wasOk = initOk; // Pokud ne, v tmp jsou nahodna data.
}
if (wasOk) {
TPIXEL * src = tmpData;
int srcWidth = tmpWidth;
int xSrcMin = crop.tl.y;
int xSrcMax = crop.br.y;
int ySrcMin = crop.tl.x;
int ySrcMax = crop.br.x;
TPIXEL * dst = srcData;
int dstWidth = origWidth;
int xDstMin = crop.tl.x;
int yDstMin = crop.tl.y;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
double * kernel = yKernel;
int kernelCenter = yKernelCenter;
int kernelWidth = yKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
TCHANNEL doa;
double da;
double sa;
double sac;
double ra;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
doa = *(chPtr + 3);
da = doa / 255.0;
sa = sumA * alpha / 255.0;
sac = 1 - sa;
ra = sa + da * sac;
*chPtr = ((sumR / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumG / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumB / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ra * 255 + 0.5;,
dPtr += dstWidth;
)
}
free(tmpData);
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TSeparableFilter< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig
| ) |  |
| protectedvirtualinherited

Reimplemented from app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 564 of file TSeparableFilter.cpp.

{
if (this->chCount != 4) {
return 1;
}
if (xKernel == NULL || yKernel == NULL) {
return 2;
} // pro mensi nez 2 se nepodari vytvorit reindexer, zkolabuje, navic je cely nesmysl - bodova operace v danem smeru
TPIXEL * const srcData = bitmap.getData();
if (srcData == NULL) {
return 3;
}
unsigned origWidth = bitmap.getWidth();
unsigned origHeight = bitmap.getHeight();
unsigned tmpWidth = origHeight;
unsigned tmpHeight = origWidth;
TPIXEL * const tmpData = (TPIXEL *) malloc(tmpWidth * tmpHeight * sizeof(TPIXEL)); // Dočasná bitmapa, do které se provede filtr dle řádků a ze které se filtruje dle sloupců do původní bitmapy.
if (tmpData == NULL) {
delete tmpData;
return 4;
}
PointerArea mskArea(mask.getData(), mask.getRect(), mskRect, mask.getBpp());
PointerArea dstArea = bitmap.getPointerArea();
int err = PointerArea::makeCommon(dstArea, mskArea, mskOrig);
if (err) {
return 100 + err;
}
Rect crop = dstArea.getArea();
Rect mskCrop = mskArea.getArea();
int wasOk = 0;
{
TPIXEL * src = srcData;
int srcWidth = origWidth;
int xSrcMin = crop.tl.x;
int xSrcMax = crop.br.x;
int ySrcMin = crop.tl.y - yKernelCenter;
ySrcMin = (ySrcMin < 0) ? 0 : ySrcMin;
int ySrcMax = crop.br.y + yKernelCenter;
ySrcMax = (ySrcMax > origHeight) ? origHeight : ySrcMax;
TPIXEL * dst = tmpData;
int dstWidth = tmpWidth;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
int xDstMin = ySrcMin;
int yDstMin = xSrcMin;
double * kernel = xKernel;
int kernelCenter = xKernelCenter;
int kernelWidth = xKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
*chPtr = sumR / (sumA) + 0.5; chPtr++;
*chPtr = sumG / (sumA) + 0.5; chPtr++;
*chPtr = sumB / (sumA) + 0.5; chPtr++;
*chPtr = sumA + 0.5;,
dPtr += dstWidth;
)
wasOk = initOk; // Pokud ne, v tmp jsou nahodna data.
}
if (wasOk) {
TPIXEL * src = tmpData;
int srcWidth = tmpWidth;
int xSrcMin = crop.tl.y;
int xSrcMax = crop.br.y;
int ySrcMin = crop.tl.x;
int ySrcMax = crop.br.x;
TPIXEL * dst = srcData;
int dstWidth = origWidth;
int xDstMin = crop.tl.x;
int yDstMin = crop.tl.y;
TCHANNEL * msk = mask.getData();
int mskWidth = mask.getWidth();
int xMskMin = mskCrop.tl.x;
int yMskMin = mskCrop.tl.y;
double * kernel = yKernel;
int kernelCenter = yKernelCenter;
int kernelWidth = yKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
TCHANNEL doa;
double da;
double sa;
double sac;
double ra;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;
mPtr = mPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
doa = *(chPtr + 3);
da = doa / 255.0;
sa = sumA * *mPtr/ 65025.0;
sac = 1 - sa;
ra = sa + da * sac;
*chPtr = ((sumR / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumG / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumB / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ra * 255 + 0.5;,
dPtr += dstWidth;
mPtr += mskWidth;
)
}
free(tmpData);
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TSeparableFilter< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | bitmap,
|  | TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig,
|  | double | alpha
| ) |  |
| protectedvirtualinherited

Reimplemented from app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 739 of file TSeparableFilter.cpp.

{
if (this->chCount != 4) {
return 1;
}
if (xKernel == NULL || yKernel == NULL) {
return 2;
} // pro mensi nez 2 se nepodari vytvorit reindexer, zkolabuje, navic je cely nesmysl - bodova operace v danem smeru
TPIXEL * const srcData = bitmap.getData();
if (srcData == NULL) {
return 3;
}
unsigned origWidth = bitmap.getWidth();
unsigned origHeight = bitmap.getHeight();
unsigned tmpWidth = origHeight;
unsigned tmpHeight = origWidth;
TPIXEL * const tmpData = (TPIXEL *) malloc(tmpWidth * tmpHeight * sizeof(TPIXEL)); // Dočasná bitmapa, do které se provede filtr dle řádků a ze které se filtruje dle sloupců do původní bitmapy.
if (tmpData == NULL) {
delete tmpData;
return 4;
}
PointerArea mskArea(mask.getData(), mask.getRect(), mskRect, mask.getBpp());
PointerArea dstArea = bitmap.getPointerArea();
int err = PointerArea::makeCommon(dstArea, mskArea, mskOrig);
if (err) {
return 100 + err;
}
Rect crop = dstArea.getArea();
Rect mskCrop = mskArea.getArea();
int wasOk = 0;
{
TPIXEL * src = srcData;
int srcWidth = origWidth;
int xSrcMin = crop.tl.x;
int xSrcMax = crop.br.x;
int ySrcMin = crop.tl.y - yKernelCenter;
ySrcMin = (ySrcMin < 0) ? 0 : ySrcMin;
int ySrcMax = crop.br.y + yKernelCenter;
ySrcMax = (ySrcMax > origHeight) ? origHeight : ySrcMax;
TPIXEL * dst = tmpData;
int dstWidth = tmpWidth;
TCHANNEL * msk = NULL;
int mskWidth = 0;
int xMskMin = 0;
int yMskMin = 0;
int xDstMin = ySrcMin;
int yDstMin = xSrcMin;
double * kernel = xKernel;
int kernelCenter = xKernelCenter;
int kernelWidth = xKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
*chPtr = sumR / (sumA) + 0.5; chPtr++;
*chPtr = sumG / (sumA) + 0.5; chPtr++;
*chPtr = sumB / (sumA) + 0.5; chPtr++;
*chPtr = sumA + 0.5;,
dPtr += dstWidth;
)
wasOk = initOk; // Pokud ne, v tmp jsou nahodna data.
}
if (wasOk) {
TPIXEL * src = tmpData;
int srcWidth = tmpWidth;
int xSrcMin = crop.tl.y;
int xSrcMax = crop.br.y;
int ySrcMin = crop.tl.x;
int ySrcMax = crop.br.x;
TPIXEL * dst = srcData;
int dstWidth = origWidth;
int xDstMin = crop.tl.x;
int yDstMin = crop.tl.y;
TCHANNEL * msk = mask.getData();
int mskWidth = mask.getWidth();
int xMskMin = mskCrop.tl.x;
int yMskMin = mskCrop.tl.y;
double * kernel = yKernel;
int kernelCenter = yKernelCenter;
int kernelWidth = yKernelWidth;
double sumR;
double sumG;
double sumB;
double sumA;
double A;
TCHANNEL * chPtr;
double kv;
TCHANNEL doa;
double da;
double sa;
double sac;
double ra;
SEPARABLE_FILTER_ALGORITHM_GENERAL(
dPtr = dPtrColBgn++;
mPtr = mPtrColBgn++;,
sumR = 0; sumG = 0; sumB = 0; sumA = 0;,
kv = *kernelPtr;
chPtr = (TCHANNEL *) sTmpPtr;
A = *(chPtr + 3) * kv;
sumR += *(chPtr++) * A;
sumG += *(chPtr++) * A;
sumB += *chPtr * A;
sumA += A;,
chPtr = (TCHANNEL *) dPtr;
doa = *(chPtr + 3);
da = doa / 255.0;
sa = sumA * *mPtr * alpha / 65025.0;
sac = 1 - sa;
ra = sa + da * sac;
*chPtr = ((sumR / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumG / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ((sumB / (sumA)) * sa + *chPtr * da * sac) / ra + 0.5; chPtr++;
*chPtr = ra * 255 + 0.5;,
dPtr += dstWidth;
mPtr += mskWidth;
)
}
free(tmpData);
return 0;
}
template<typename TPIXEL, typename TCHANNEL>

virtual int app::TSeparableFilter< TPIXEL, TCHANNEL >::isInitOk | ( |  | ) |
| inlinevirtualinherited

Implements app::TFilter< TPIXEL, TCHANNEL >.

Definition at line 62 of file TSeparableFilter.hpp.

{
if (xKernel != NULL && yKernel != NULL) {
return 1;
} else {
return 0;
}
}

## Member Data Documentation

template<typename TPIXEL, typename TCHANNEL>

const unsigned TFilter< TPIXEL, TCHANNEL >::chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
| staticprotectedinherited

Počet kanálů bitmapy.

Definition at line 27 of file TFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

const TCHANNEL TFilter< TPIXEL, TCHANNEL >::maxVal = ~0
| staticprotectedinherited

Maximální hodnota kanálu.

Definition at line 26 of file TFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

double* app::TSeparableFilter< TPIXEL, TCHANNEL >::xKernel
| protectedinherited

Jádro použité v prvním průchodu - horizontální směr.

Definition at line 39 of file TSeparableFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

int app::TSeparableFilter< TPIXEL, TCHANNEL >::xKernelCenter
| protectedinherited

Souřadnice prvku přesně uprostřed horizontálního jádra.

Definition at line 41 of file TSeparableFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

int app::TSeparableFilter< TPIXEL, TCHANNEL >::xKernelWidth
| protectedinherited

Šířka horizontálního jádra.

Definition at line 40 of file TSeparableFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

double* app::TSeparableFilter< TPIXEL, TCHANNEL >::yKernel
| protectedinherited

Jádro použité v druhém průchodu - vertikální směr.

Definition at line 43 of file TSeparableFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

int app::TSeparableFilter< TPIXEL, TCHANNEL >::yKernelCenter
| protectedinherited

Souřadnice prvku přesně uprostřed vertikálního jádra.

Definition at line 45 of file TSeparableFilter.hpp.

template<typename TPIXEL, typename TCHANNEL>

int app::TSeparableFilter< TPIXEL, TCHANNEL >::yKernelWidth
| protectedinherited

Šířka vertikálního jádra.

Definition at line 44 of file TSeparableFilter.hpp.

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

- /home/xxx/eclipse_workspaces/app/appcore/jni/app/filters/TGaussianBlur.hpp
- /home/xxx/eclipse_workspaces/app/appcore/jni/app/filters/TGaussianBlur.cpp