FEDRA emulsion software from the OPERA Collaboration
EdbFIRF Class Reference

FIR filter. More...

#include <EdbIP.h>

Inheritance diagram for EdbFIRF:
Collaboration diagram for EdbFIRF:

Public Member Functions

TH2F * ApplyTo (EdbImage *img)
 
float Cell (int x, int y)
 
 EdbFIRF ()
 
 EdbFIRF (const char *firf)
 
 EdbFIRF (int cols, int rows)
 
float * GetBuffer () const
 
void Print ()
 
void Reflect4 ()
 Copy left top corner to other quadrants with reflection. More...
 
void SetArr (int n, float *arr)
 
void SetAt (int x, int y, float a)
 
virtual ~EdbFIRF ()
 

Static Public Member Functions

static void PrintList ()
 

Private Attributes

TArrayF * eArr
 
Int_t eColumns
 number of columns of the matrix (1 row length) More...
 
Int_t eRows
 number of rows of the matrix More...
 

Static Private Attributes

static const Float_t eg3x3A []
 
static const Float_t eg5x5A []
 
static const Float_t eg5x5B []
 
static const Float_t eg5x5C []
 
static const Float_t eg6x6A []
 
static const Float_t egHP1 []
 
static const Float_t egHP2 []
 
static const Float_t egHP3 []
 

Detailed Description

FIR filter.

Constructor & Destructor Documentation

◆ EdbFIRF() [1/3]

EdbFIRF::EdbFIRF ( )
inline
40{};

◆ EdbFIRF() [2/3]

EdbFIRF::EdbFIRF ( int  cols,
int  rows 
)
71{
72 eArr = new TArrayF();
73 eArr->Adopt(cols*rows, new float[cols*rows]);
74 eColumns=cols;
75 eRows=rows;
76 eArr->Reset();
77}
Int_t eColumns
number of columns of the matrix (1 row length)
Definition: EdbIP.h:27
Int_t eRows
number of rows of the matrix
Definition: EdbIP.h:28
TArrayF * eArr
Definition: EdbIP.h:26

◆ EdbFIRF() [3/3]

EdbFIRF::EdbFIRF ( const char *  firf)
81{
82 SetName(firf);
83 eArr = new TArrayF();
84 if( !strcmp(firf,"HP1") ) {
85 eColumns=3;
86 eRows=3;
88 } else if( !strcmp(firf,"HP2") ) {
89 eColumns=3;
90 eRows=3;
92 } else if( !strcmp(firf,"HP3") ) {
93 eColumns=3;
94 eRows=3;
96 } else if( !strcmp(firf,"3x3A") ) {
97 eColumns=3;
98 eRows=3;
100 } else if( !strcmp(firf,"5x5A") ) {
101 eColumns=5;
102 eRows=5;
104 } else if( !strcmp(firf,"5x5B") ) {
105 eColumns=5;
106 eRows=5;
108 } else if( !strcmp(firf,"5x5C") ) {
109 eColumns=5;
110 eRows=5;
112 } else if( !strcmp(firf,"6x6A") ) {
113 eColumns=6;
114 eRows=6;
116 }
117 Print();
118}
graph SetName("Graph")
static const Float_t egHP3[]
Definition: EdbIP.h:33
void Print()
Definition: EdbIP.cxx:143
static const Float_t egHP1[]
Definition: EdbIP.h:31
static const Float_t egHP2[]
Definition: EdbIP.h:32
static const Float_t eg5x5A[]
Definition: EdbIP.h:34
static const Float_t eg5x5C[]
Definition: EdbIP.h:36
static const Float_t eg3x3A[]
Definition: EdbIP.h:30
static const Float_t eg5x5B[]
Definition: EdbIP.h:35
static const Float_t eg6x6A[]
Definition: EdbIP.h:37

◆ ~EdbFIRF()

EdbFIRF::~EdbFIRF ( )
virtual
122{
123 if(eArr) { delete eArr; eColumns=0; eRows=0; }
124}

Member Function Documentation

◆ ApplyTo()

TH2F * EdbFIRF::ApplyTo ( EdbImage img)
167{
168 int x0=eColumns/2+1;
169 int y0=eRows/2+1;
170 int x1=img->Width()-x0-1;
171 int y1=img->Height()-y0-1; //margins
172 Float_t S;
173
174 TH2F* buf=new TH2F("img","Filtered image",
175 img->Width(),0,img->Width(),img->Height(),0,img->Height());
176
177 for(int y=y0;y<y1;y++) for(int x=x0;x<x1;x++){
178 S=0;
179 for(int yf=0;yf<eRows;yf++) for(int xf=0;xf<eColumns;xf++){
180 S+=img->Pixel(x+xf-eColumns/2,y+yf-eRows/2)*Cell(xf,yf);
181 }
182 buf->Fill(x,y,S);
183 }
184
185 return buf;
186}
float Cell(int x, int y)
Definition: EdbIP.h:45
Int_t Height() const
Definition: EdbImage.h:60
Int_t Width() const
Definition: EdbImage.h:59
int Pixel(int c, int r) const
Definition: EdbImage.h:50

◆ Cell()

float EdbFIRF::Cell ( int  x,
int  y 
)
inline
45{ return eArr->At(eColumns*y + x); }

◆ GetBuffer()

float * EdbFIRF::GetBuffer ( ) const
inline
46{ return eArr->GetArray(); }

◆ Print()

void EdbFIRF::Print ( )
144{
145 printf("FIR filter: %s\n",GetName());
146 float sum=0;
147 for(int i=0;i<eRows;i++){
148 for(int j=0;j<eColumns;j++){
149 printf("%3.1f\t",Cell(j,i));
150 sum+=Cell(j,i);
151 }
152 printf("\n");
153 }
154 printf("\nSum = %f\n",sum);
155}

◆ PrintList()

void EdbFIRF::PrintList ( )
static
159{
160 printf("known 3x3 filtres: \n\t3x3A \n\tHP1 \n\tHP2 \n\tHP3 \n");
161 printf("known 5x5 filtres: \n\t5x5A \n\t5x5B \n\t5x5C \n");
162 printf("known 6x6 filtres: \n\t6x6A \n");
163}

◆ Reflect4()

void EdbFIRF::Reflect4 ( )

Copy left top corner to other quadrants with reflection.

128{
129 int X=eColumns;
130 int Y=eRows;
131 int HX=(int)((eColumns+1)/2);
132 int HY=(int)((eRows+1)/2);
133 for(int i=0;i<HY;i++){
134 for(int j=0;j<HX;j++){
135 SetAt(X-j-1,i,Cell(j,i));
136 SetAt(X-j-1,Y-i-1,Cell(j,i));
137 SetAt(j,Y-i-1,Cell(j,i));
138 }
139 }
140}
void SetAt(int x, int y, float a)
Definition: EdbIP.h:48
Double_t X
Definition: tlg2couples.C:76
Double_t Y
Definition: tlg2couples.C:76

◆ SetArr()

void EdbFIRF::SetArr ( int  n,
float *  arr 
)
inline
47{}

◆ SetAt()

void EdbFIRF::SetAt ( int  x,
int  y,
float  a 
)
inline
48{ (eArr->GetArray())[eColumns*y + x]=a; }
void a()
Definition: check_aligned.C:59

Member Data Documentation

◆ eArr

TArrayF* EdbFIRF::eArr
private

◆ eColumns

Int_t EdbFIRF::eColumns
private

number of columns of the matrix (1 row length)

◆ eg3x3A

const Float_t EdbFIRF::eg3x3A[]
staticprivate

◆ eg5x5A

const Float_t EdbFIRF::eg5x5A
staticprivate
Initial value:
= {
4, 4, 4, 4, 4,
4, -7, -7, -7, 4,
4, -7, -7, -7, 4,
4, -7, -7, -7, 4,
4, 4, 4, 4, 4 }

◆ eg5x5B

const Float_t EdbFIRF::eg5x5B
staticprivate
Initial value:
= {
4, 4, 4, 4, 4,
4, -7, -7, -7, 4,
4, -7, -8, -7, 4,
4, -7, -7, -7, 4,
4, 4, 4, 4, 4 }

◆ eg5x5C

const Float_t EdbFIRF::eg5x5C
staticprivate
Initial value:
= {
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, -24, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1 }

◆ eg6x6A

const Float_t EdbFIRF::eg6x6A
staticprivate
Initial value:
= {
4, 4, 4, 4, 4, 4,
4, -5, -5, -5, -5, 4,
4, -5, -5, -5, -5, 4,
4, -5, -5, -5, -5, 4,
4, -5, -5, -5, -5, 4,
4, 4, 4, 4, 4, 4 }

◆ egHP1

const Float_t EdbFIRF::egHP1
staticprivate
Initial value:
= {
1, 1, 1,
1, -9, 1,
1, 1, 1 }

◆ egHP2

const Float_t EdbFIRF::egHP2
staticprivate
Initial value:
= {
0, 1, 0,
1, -5, 1,
0, 1, 0 }

◆ egHP3

const Float_t EdbFIRF::egHP3
staticprivate
Initial value:
= {
-1, 2, -1,
2, -5, 2,
-1, 2, -1 }

◆ eRows

Int_t EdbFIRF::eRows
private

number of rows of the matrix


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