FEDRA emulsion software from the OPERA Collaboration
TByteMatrix Class Reference

#include <bytematrix.h>

Inheritance diagram for TByteMatrix:
Collaboration diagram for TByteMatrix:

Public Member Functions

void Add1 (long i, long j)
 
void ClearAll (void)
 
void ClearByte (long i, long j)
 
void GetAngle (double *tgx, double *tgy)
 
int GetByte (int type, long i, long j)
 
int GetElement (int type, long i, long j)
 
TByteMatrixoperator+= (TBitMatrix &TBit)
 
TByteMatrixoperator+= (TByteMatrix &TByt)
 
TObjArray * Pick8 (int type, int thr)
 
void SetAngle (double tgx, double tgy)
 
void SetByte (long i, long j, unsigned char byte=0xff)
 
 TByteMatrix ()
 
 TByteMatrix (long x_size, long y_size)
 
 TByteMatrix (long x_size, long y_size, double tgx, double tgy)
 
 TByteMatrix (TBaseMatrix &T)
 
virtual ~TByteMatrix ()
 
- Public Member Functions inherited from TBaseMatrix
void Adopt (unsigned char *mas, long rows, long columns)
 
long GetSize (long *ix_size=NULL, long *iy_size=NULL)
 
void Init (long ix_size, long iy_size)
 
void MoveMatrix (long ud, long lr)
 
TBaseMatrixoperator= (TBaseMatrix &T)
 
void Print (int type)
 
void ResetShift (void)
 
 TBaseMatrix ()
 
 TBaseMatrix (long ix_size, long iy_size)
 
 TBaseMatrix (TBaseMatrix &iT)
 
virtual ~TBaseMatrix ()
 

Protected Attributes

double Tgx
 
double Tgy
 
- Protected Attributes inherited from TBaseMatrix
long byteSize
 
unsigned char * mas
 
long shiftX
 
long shiftY
 
long xSize
 
long ySize
 

Additional Inherited Members

- Protected Member Functions inherited from TBaseMatrix
const unsigned char * GetPointer (void)
 

Constructor & Destructor Documentation

◆ TByteMatrix() [1/4]

TByteMatrix::TByteMatrix ( )
13  :TBaseMatrix() {
14 // TBaseMatrix();
15 /* xSize=0;
16  ySize=0;
17  byteSize=0;
18  mas = NULL;
19 
20  xSize=0;
21  ySize=0;
22  byteSize=0;
23  mas = NULL;
24  shiftX=0;
25  shiftY=0;
26  position = 0;
27  NonZeroPoints = new TObjArray();
28 */
29 }
TBaseMatrix()
Definition: basematrix.cxx:25

◆ TByteMatrix() [2/4]

TByteMatrix::TByteMatrix ( long  x_size,
long  y_size 
)
33  :TBaseMatrix(x,y) {
34 // TByteMatrix();
35 /* xSize = x;
36  ySize = y;
37  long bitSize = xSize*ySize;
38  byteSize = (long)(bitSize/8) + (bitSize%8)?1:0;
39  mas = (unsigned char *)calloc(byteSize,sizeof(unsigned char));
40 
41  Init(x,y);
42 */}

◆ TByteMatrix() [3/4]

TByteMatrix::TByteMatrix ( long  x_size,
long  y_size,
double  tgx,
double  tgy 
)
45  :TBaseMatrix(x_size,y_size)
46 {
47 // Init(x_size,y_size);
48  Tgx = tgx;
49  Tgy = tgy;
50 }
double Tgy
Definition: bytematrix.h:20
double Tgx
Definition: bytematrix.h:20

◆ TByteMatrix() [4/4]

TByteMatrix::TByteMatrix ( TBaseMatrix T)
52  :TBaseMatrix(T)
53 {
54 /* long xs,ys;
55  T.GetSize(&xs,&ys);
56  Init(xs,ys);
57 */}

◆ ~TByteMatrix()

TByteMatrix::~TByteMatrix ( )
virtual
61  {
62 /* if (imas) {
63  free(imas);
64  imas = NULL;
65  }
66  if (cmas) {
67  free(cmas);
68  cmas = NULL;
69  }
70  ixSize=0;
71  iySize=0;
72  ibyteSize=0;
73 
74  cxSize=0;
75  cySize=0;
76  cbyteSize=0;
77 */}

Member Function Documentation

◆ Add1()

void TByteMatrix::Add1 ( long  i,
long  j 
)
175 {
176  long byt = xSize * j + i;
177  mas[byt]++;
178 /* MyPoint *point = 0;
179  int n = NonZeroPoints->GetEntries();
180  for (int k=0; k<n; k++) {
181  point = (MyPoint *)(NonZeroPoints->At(k));
182  if ((point->x == i)&&(point->y == j)) return;
183  }
184  NonZeroPoints->Add(new MyPoint(i,j,0));
185 */
186 }
long xSize
Definition: basematrix.h:22
unsigned char * mas
Definition: basematrix.h:30

◆ ClearAll()

void TByteMatrix::ClearAll ( void  )
168 {
169  memset((void *)mas,0,byteSize);
170 // NonZeroPoints->Delete();
171 }
long byteSize
Definition: basematrix.h:24

◆ ClearByte()

void TByteMatrix::ClearByte ( long  i,
long  j 
)
149 {
150  long byt = xSize * j + i;
151 // int byte = (int)(xSize/8)*j + (int)(i/8);
152 // int bit_byte = i%8;
153  mas[byt] &=0x00 ;
154 /* MyPoint *point = 0;
155  int n = NonZeroPoints->GetEntries();
156  for (int k=0; k<n; k++) {
157  point = (MyPoint *)(NonZeroPoints->At(k));
158  if ((point->x == i)&&(point->y == j)) {
159  delete NonZeroPoints->RemoveAt(k);
160  NonZeroPoints->Compress();
161  break;
162  }
163  }
164 */
165 }

◆ GetAngle()

void TByteMatrix::GetAngle ( double *  tgx,
double *  tgy 
)
100 {
101  *tgx = Tgx;
102  *tgy = Tgy;
103 }

◆ GetByte()

int TByteMatrix::GetByte ( int  type,
long  i,
long  j 
)
107 {
108  long shi, shj, shx, shy;
109  if (type==0) {
110  shx = 0;
111  shy = 0;
112  }
113  else if (type==1) {
114  shx = shiftX;
115  shy = shiftY;
116  }
117  else {
118  cout<<"UNKNOWN GETBIT TYPE"<<endl;
119  return 0;
120  }
121  shi = i - shx;
122  shj = j - shy;
123  if ((shi>=xSize)||(shj>=ySize)||(shi<0)||(shj<0)) return 0;
124  long byte = xSize * shj + shi;
125  return mas[byte];
126 }
long shiftX
Definition: basematrix.h:36
long ySize
Definition: basematrix.h:23
long shiftY
Definition: basematrix.h:37
Int_t type
Definition: testBGReduction_By_ANN.C:15

◆ GetElement()

int TByteMatrix::GetElement ( int  type,
long  i,
long  j 
)
inlinevirtual

Implements TBaseMatrix.

35 {return GetByte(type,i,j);}
int GetByte(int type, long i, long j)
Definition: bytematrix.cxx:106

◆ operator+=() [1/2]

TByteMatrix & TByteMatrix::operator+= ( TBitMatrix TBit)
293 {
294  long xthis,ythis,x2,y2;
295  GetSize(&xthis,&ythis);
296  TBit.GetSize(&x2,&y2);
297  long xs = (x2<xthis)?x2:xthis;
298  long ys = (y2<ythis)?y2:ythis;
299 // TByteMatrix* TByte = new TByteMatrix(xs,ys);
300 /* long i,j;
301  if (TBit.FirstPoint(1,&i,&j)) Add1(i,j);
302  while (TBit.NextPoint(1,&i,&j)) {
303  Add1(i,j);
304  }
305 */
306  for (long j=0; j<ys; j++) {
307  for (long i=0; i<xs; i++) {
308  if (TBit.GetBit(1,i,j)) Add1(i,j);
309  }
310  }
311 
312  return *this;
313 }
long GetSize(long *ix_size=NULL, long *iy_size=NULL)
Definition: basematrix.cxx:190
int GetBit(int type, long i, long j)
Definition: bitmatrix.cxx:94
void Add1(long i, long j)
Definition: bytematrix.cxx:174

◆ operator+=() [2/2]

TByteMatrix & TByteMatrix::operator+= ( TByteMatrix TByt)
317 {
318  long xthis,ythis,x2,y2;
319  GetSize(&xthis,&ythis);
320  TByt.GetSize(&x2,&y2);
321  long xs = (x2<xthis)?x2:xthis;
322  long ys = (y2<ythis)?y2:ythis;
323 // TByteMatrix* TByte = new TByteMatrix(xs,ys);
324 /* long i,j;
325  if (TByt.FirstPoint(1,&i,&j))
326  if (int b = TByt.GetByte(1,i,j)) SetByte(i,j,GetByte(0,i,j)+b);
327  while (TByt.NextPoint(1,&i,&j)) {
328  if (int b = TByt.GetByte(1,i,j)) SetByte(i,j,GetByte(0,i,j)+b);
329  }
330 */
331  for (long j=0; j<ys; j++) {
332  for (long i=0; i<xs; i++) {
333  if (int b = TByt.GetByte(1,i,j)) SetByte(i,j,GetByte(0,i,j)+b);
334  }
335  }
336  return *this;
337 }
void SetByte(long i, long j, unsigned char byte=0xff)
Definition: bytematrix.cxx:130

◆ Pick8()

TObjArray * TByteMatrix::Pick8 ( int  type,
int  thr 
)
341 {
342 //This is a modified code from Valeri's FEDRA
343  int xn[8] = { 1, -1, 0, 0, 1, 1, -1, -1 }; //pixel 3x3 suburbs
344  int yn[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
345  TObjArray* Ta = new TObjArray();
346  long nc,nr;
347  GetSize(&nc,&nr);
348  int pix,pp,pix1;
349 
350 // printf("hist: %d %d\n",nc,nr);
351 // int npeaks=0;
352  int ic,ir,in; // declare here to fix marazmatic eror messages of VC++
353  for(ic=2; ic<nc-3; ic++) {
354  for(ir=2; ir<nr-3; ir++) {
355 
356  pix = GetByte(type,ic,ir);
357  if( pix < thr) goto NEXTPIX;
358  pix1=pix+1;
359 
360  for(in=0; in<8; in++) {
361  pp = GetByte(type, ic+xn[in], ir+yn[in] );
362  if( pix1 <= pp ) goto NEXTPIX; //it was <=
363  SetByte(ic,ir,pix1);
364  }
365 // printf("peak8(%d,%d) = %d\n",ic,ir,pix);
366  Ta->Add(new MyPoint(ic,ir,pix));
367 NEXTPIX:
368  continue;
369  }
370  }
371  return Ta;
372 }
Definition: basematrix.h:9

◆ SetAngle()

void TByteMatrix::SetAngle ( double  tgx,
double  tgy 
)
93 {
94  Tgx = tgx;
95  Tgy = tgy;
96 }

◆ SetByte()

void TByteMatrix::SetByte ( long  i,
long  j,
unsigned char  byte = 0xff 
)
131 {
132  long byt = xSize * j + i;
133 // int byte = (int)(xSize/8)*j + (int)(i/8);
134 // int bit_byte = i%8;
135  mas[byt] =byte ;
136 /* MyPoint *point = 0;
137  int n = NonZeroPoints->GetEntries();
138  for (int k=0; k<n; k++) {
139  point = (MyPoint *)(NonZeroPoints->At(k));
140  if ((point->x == i)&&(point->y == j)) return;
141  }
142  NonZeroPoints->Add(new MyPoint(i,j,0));
143 */
144 }

Member Data Documentation

◆ Tgx

double TByteMatrix::Tgx
protected

◆ Tgy

double TByteMatrix::Tgy
protected

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