#include <EdbImage.h>
◆ EdbImage() [1/3]
◆ EdbImage() [2/3]
| EdbImage::EdbImage |
( |
const char * |
file, |
|
|
const char * |
format = "PGM" |
|
) |
| |
37 if ( !strcmp(format,
"PGM") ) counter =
LoadPGM(
file);
38 else if ( !strcmp(format,
"RAW") ) counter =
LoadRAW(
file);
39 else if ( !strcmp(format,
"BMP") ) counter =
LoadBMP(
file);
41 printf(
"counter = %d\n",counter);
43 printf(
"ERROR: EdbImage::EdbImage: counter != eBytes \n");
Int_t LoadBMP(const char *file)
Definition: EdbImage.cxx:307
TArrayC * eBuffer
Definition: EdbImage.h:32
virtual void Set0()
Definition: EdbImage.cxx:80
Int_t eBytes
Definition: EdbImage.h:33
Int_t LoadRAW(const char *file)
Definition: EdbImage.cxx:181
Int_t LoadPGM(const char *file)
Definition: EdbImage.cxx:216
TFile * file
Definition: write_pvr.C:3
◆ EdbImage() [3/3]
| EdbImage::EdbImage |
( |
int |
columns, |
|
|
int |
rows, |
|
|
const char * |
image, |
|
|
int |
col = 256 |
|
) |
| |
99 char *buffer =
new char[
s];
103 int size = (int)strlen(image); printf(
"strlen(image) = %d\n",size);
105 memcpy((
void *)buffer,(
const void *)image,
eBytes);
Int_t eColors
Definition: EdbImage.h:30
Int_t eColumns
Definition: EdbImage.h:27
Int_t eRows
Definition: EdbImage.h:28
EdbSegP * s
Definition: tlg2pattern.C:32
◆ ~EdbImage()
◆ AdoptImage()
| void EdbImage::AdoptImage |
( |
int |
columns, |
|
|
int |
rows, |
|
|
char * |
image, |
|
|
int |
col = 256 |
|
) |
| |
◆ DumpPGM()
| Int_t EdbImage::DumpPGM |
( |
const char * |
file | ) |
|
285 FILE *out = fopen(
file,
"w" );
289 fprintf(out,
"255\n");
292 unsigned char *buf = (
unsigned char*)(
eBuffer->GetArray());
294 for(
int istr=0; istr<16; istr++) {
295 fprintf(out,
"%d ",(
int)(buf[ibyte]));
297 if(ibyte>=nbytes)
break;
300 if(ibyte>nbytes-1)
break;
Int_t Height() const
Definition: EdbImage.h:60
Int_t Width() const
Definition: EdbImage.h:59
◆ FillBufferDouble()
| Int_t EdbImage::FillBufferDouble |
( |
TArrayD & |
image | ) |
const |
126 if(npix<=0)
return 0;
128 for(
int i=0; i<npix; i++) image[i]=(Double_t)(
Pixel(i));
int Pixel(int c, int r) const
Definition: EdbImage.h:50
◆ GetBuffer()
| char* EdbImage::GetBuffer |
( |
| ) |
const |
|
inline |
◆ GetHist1()
| TH1F * EdbImage::GetHist1 |
( |
| ) |
const |
141 TH1F *
hist =
new TH1F(
"pix",
"Pixels distribution",
144 unsigned char *buf = (
unsigned char*)(
eBuffer->GetArray());
146 for (
int icl=0; icl<
eColumns; icl++) {
147 for (
int ir=0; ir<
eRows; ir++) {
149 hist->Fill( (
int)(buf[i]) );
void hist()
Definition: init.C:23
◆ GetHist2()
| TH2F * EdbImage::GetHist2 |
( |
int |
flip = 0 | ) |
const |
159 TH2F *
hist =
new TH2F(
"ccd",
"CCD image",
163 unsigned char *buf = (
unsigned char*)(
eBuffer->GetArray());
167 for (
int icl=0; icl<
eColumns; icl++) {
168 for (
int ir=0; ir<
eRows; ir++) {
172 hist->Fill( icl, ir, pix );
◆ Height()
| Int_t EdbImage::Height |
( |
| ) |
const |
|
inline |
◆ LoadBMP()
| Int_t EdbImage::LoadBMP |
( |
const char * |
file | ) |
|
314 unsigned short int type;
316 unsigned short int reserved1, reserved2;
323 unsigned short int planes;
324 unsigned short int bits;
325 unsigned int compression;
326 unsigned int imagesize;
327 int xresolution,yresolution;
328 unsigned int ncolours;
329 unsigned int importantcolours;
337 ifstream raw(
file,ios::in | ios::binary);
342 if(ihdr.bits!=8) { printf(
"Error: %d bits/pixel bitmap is not supported!\n",ihdr.bits);
return -1;}
343 int N=ihdr.width*ihdr.height;
344 char*
byte=
new char[N];
355 printf(
"EdbImage::LoadBMP: file %s is readed...Image %d x %d pixels.\n",
file,
eColumns,
eRows);
float width
Definition: emthickness.cpp:71
Int_t type
Definition: testBGReduction_By_ANN.C:15
◆ LoadPGM()
| Int_t EdbImage::LoadPGM |
( |
const char * |
file | ) |
|
222 int colors, pix, i, j, p2, p5=0;
223 char Id[10], Buffer[BUFSIZ];
224 FILE *in = fopen(
file,
"rb" );
229 if( (p2 = strncmp(Id,
"P2", 2)) && (p5 = strncmp(Id,
"P5", 2)) )
231 printf(
"LoadPGM: Error Id\n");
return 0;
234 while( (fgets(Buffer, BUFSIZ, in) !=
NULL) && (*Buffer ==
'#') )
237 if( sscanf(Buffer,
"%d %d", &NRows, &NCols) != 2 )
238 { printf(
"LoadPGM: Error NRows, &NCols\n");
return 0; }
244 if( fscanf(in,
"%d\n", &colors) != 1 )
245 { printf(
"LoadPGM: Error\n");
return 0; }
250 printf(
"LoadPGM: Warning: colors = %d \n", colors);
252 char *
Pixel =
new char[NRows * NCols + save];
257 for( j = 0; j < NRows; j++ )
258 for( i = 0; i < NCols; i++ )
260 if( fscanf(in,
"%d", &pix) != 1 ) printf(
"LoadPGM: Error\n");
261 Pixel[j * NCols + i] = pix;
265 else if( !p5 && ((counter = fread((
void *)
Pixel, 1, NRows * NCols, in)) !=
eBytes) )
267 printf(
"LoadPGM: Error loading binary file\n" );
275 printf(
"EdbImage::LoadPGM: file %s is readed...\n",
file);
#define NULL
Definition: nidaqmx.h:84
◆ LoadRAW()
| Int_t EdbImage::LoadRAW |
( |
const char * |
file | ) |
|
◆ Pixel() [1/2]
| int EdbImage::Pixel |
( |
int |
c, |
|
|
int |
r |
|
) |
| const |
|
inline |
51 {
if(
r<0)
return 0;
if(
r>
eRows)
return 0;
52 if(c<0)
return 0;
if(c>
eColumns)
return 0;
void r(int rid=2)
Definition: test.C:201
◆ Pixel() [2/2]
| int EdbImage::Pixel |
( |
int |
ipix | ) |
const |
|
inline |
55 {
return (
int)(((
unsigned char*)(
eBuffer->GetArray()))[ipix]); }
◆ Print()
| void EdbImage::Print |
( |
Option_t * |
opt = "" | ) |
const |
|
virtual |
◆ Set0()
◆ SetColors()
| void EdbImage::SetColors |
( |
int |
col | ) |
|
|
inline |
◆ Width()
| Int_t EdbImage::Width |
( |
| ) |
const |
|
inline |
◆ eBuffer
| TArrayC* EdbImage::eBuffer |
|
private |
◆ eBytes
◆ eColors
◆ eColumns
◆ eRows
The documentation for this class was generated from the following files: