Structural deformable models
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Dataset Class Reference

#include <Data.h>

Inheritance diagram for Dataset:
Inheritance graph
[legend]
Collaboration diagram for Dataset:
Collaboration graph
[legend]

Public Member Functions

 Dataset ()
 
 Dataset (const char *filename)
 
 ~Dataset ()
 
bool load (const char *filename, dword ppmm=0)
 
DatasetcopyData (const Dataset &rhs)
 
void draw (float x=0, float y=0, float sx=1.0f, float sy=1.0f) const
 
int getDim1Size () const
 
int getDim2Size () const
 
int getDim3Size () const
 
int getNChannels () const
 
std::ostream & print (std::ostream &os) const
 
void clear ()
 
bool initialized () const
 
 operator bool () const
 
const ByteImagegetImage () const
 
ByteImagegetImage ()
 
const ByteImagegetImage (int index) const
 
ByteImagegetImage (int index)
 
dword getPPMM () const
 
void setPPMM (dword ppmm)
 
const Point2DgetOrigin () const
 
const Point2DgetOSize () const
 
const std::string & getFilename () const
 
PropVec getPropVec () const
 
PropVec getPropVecMM () const
 
void setHalveBeyondSize (dword hbs=0xffffffff)
 
dword getHalveBeyondSize () const
 
void addNoise (float sigma)
 
- Public Member Functions inherited from Sensor
virtual ~Sensor ()
 
sensor_cptr getSource ()
 
virtual void changeSource (sensor_cptr _source)
 
void replaceBy (sensor_ptr target)
 
bool assignRef (sensor_cptr rhs)
 
virtual Sensorassign (const Sensor &rhs)
 
virtual float getValue (int x, int y) const
 get value at discrete position More...
 
float getValue (const Point &p) const
 get value at position p using nearest neighbour interpolation More...
 
virtual std::vector< float > getMValue (int x, int y) const
 get multi-channel value More...
 
virtual Point2D getGradient (int x, int y) const
 get gradient at discrete position More...
 
Point2D getGradient (const Point2D &p) const
 get gradient at position p using nearest neighbor interpolation More...
 
float getMax () const
 
float getMin () const
 
float getMinMaxRange () const
 
float getWeightedValue (int x, int y) const
 get max normalized value at discrete position range [0,1] More...
 
Point2D getWeightedGradient (int x, int y) const
 get range weighted gradient at discrete position More...
 
void setCWeights (const std::vector< float > &weights)
 
const std::vector< float > & getCWeights () const
 
void setDirection (const Point &dir)
 
const PointgetDirection () const
 
void setScale (float _scale)
 
float getScale () const
 
bool isModified (dword mask=UPD_ALL) const
 
void setModified (dword mask=UPD_ALL)
 
void unsetModified (dword mask=UPD_ALL)
 
bool isUpdate (dword udMask) const
 
void enableUpdate (dword udMask)
 
void disableUpdate (dword udMask)
 
virtual bool performUpdate ()
 
virtual int getSkip () const
 
bool isValid (int x, int y) const
 
virtual Image< float > createSensorImage () const
 
const std::string & getID () const
 
void setID (const std::string &id)
 
virtual std::ostream & hprint (std::ostream &os, SensorCollection *sc) const
 
void refSuperSensor (sensor_ptr super)
 
void unrefSuperSensor (sensor_ptr super)
 
void invalidateSource ()
 
template<typename Derived >
std::shared_ptr< Derived > shared_from_base ()
 

Static Public Member Functions

static bool loadImage (std::vector< Image< byte > > &image, const char *filename)
 
static void drawImage (const std::vector< Image< byte > > &image, float x=0, float y=0, float sx=1.0f, float sy=1.0f)
 
static void drawImage (const Image< byte > &image, float x=0, float y=0, float sx=1.0f, float sy=1.0f)
 
- Static Public Member Functions inherited from Sensor
static dword getStringNumber (const char *sid)
 
static void getNumberString (char sid[5], dword id)
 

Public Attributes

vuMutex writeMutex
 

Protected Member Functions

float calcValue (int x, int y) const
 
std::vector< float > calcMValue (int x, int y) const
 
void calcMinMax ()
 
- Protected Member Functions inherited from Sensor
 Sensor (dword updateMask)
 
 Sensor ()
 
virtual Point calcGradient (int x, int y) const
 

Protected Attributes

std::vector< ByteImagedata
 
int m_Dim1
 
int m_Dim2
 
int m_Dim3
 
int m_NChannels
 
int m_CurrImage
 current image More...
 
dword m_ppmm
 
std::string m_Filename
 
Point2D m_Origin
 
Point2D m_OSize
 
GLImage m_GLImage
 
bool m_RefreshImage
 
dword m_HalveBeyondSize
 
- Protected Attributes inherited from Sensor
sensor_cptr source
 
float scale
 
std::vector< float > cweights
 multi-channel weights ('color') More...
 
Point dir
 direction parameter More...
 
float maxval
 
float minval
 overall minimum and maximum More...
 
float mean
 
float stdev
 overall mean and stdev More...
 
dword toupdate
 bitflag for updates More...
 
dword updateMask
 bitflag to mask unimportant updates More...
 
std::string m_ID
 
int m_Skip
 
int m_AddSkip
 

Additional Inherited Members

- Public Types inherited from Sensor
enum  UpdateParam {
  UPD_NOTHING =0, UPD_DATA =1, UPD_SCALE =2, UPD_CWEIGHTS =4,
  UPD_DIR =8, UPD_MINMAX =16, UPD_LAST =32, UPD_ALL =0xffffffff
}
 

Detailed Description

Implements data management. Function for loading and querying the dataset. Also a set of data sheets is managed that contains preprocessed results for sensor evaluation.

Definition at line 21 of file Data.h.

Constructor & Destructor Documentation

Dataset::Dataset ( )

Default constructor

Definition at line 46 of file Data.cpp.

References Sensor::setID().

46  : data(1),
47  m_Dim1(0), m_Dim2(0), m_Dim3(0), m_NChannels(0),
49  m_HalveBeyondSize(0xffffffff)
50 {
51  setID("d0");
52 }
std::vector< ByteImage > data
Definition: Data.h:108
int m_Dim2
Definition: Data.h:111
int m_Dim3
Definition: Data.h:111
void setID(const std::string &id)
Definition: Sensor.h:129
bool m_RefreshImage
Definition: Data.h:117
dword m_HalveBeyondSize
Definition: Data.h:118
int m_NChannels
Definition: Data.h:111
int m_Dim1
Definition: Data.h:111
int m_CurrImage
current image
Definition: Data.h:112
dword m_ppmm
Definition: Data.h:113
#define DEFAULT_PPMM
Definition: Data.h:16
Dataset::Dataset ( const char *  filename)

Constructor

Definition at line 54 of file Data.cpp.

References load().

54  : m_Dim1(0), m_Dim2(0), m_Dim3(0),
55  m_NChannels(0), m_CurrImage(0),
57  m_RefreshImage(false)
58 {
59  load(filename);
60 }
int m_Dim2
Definition: Data.h:111
int m_Dim3
Definition: Data.h:111
bool m_RefreshImage
Definition: Data.h:117
bool load(const char *filename, dword ppmm=0)
Definition: Data.cpp:62
int m_NChannels
Definition: Data.h:111
int m_Dim1
Definition: Data.h:111
int m_CurrImage
current image
Definition: Data.h:112
dword m_ppmm
Definition: Data.h:113
#define DEFAULT_PPMM
Definition: Data.h:16
Dataset::~Dataset ( )
inline

Destructor

Definition at line 31 of file Data.h.

References copyData(), draw(), and load().

31 {};

Member Function Documentation

void Dataset::addNoise ( float  sigma)

Definition at line 212 of file Data.cpp.

References data, fgauss01(), and m_RefreshImage.

Referenced by getHalveBeyondSize().

213 {
214  for(vector< ByteImage >::iterator ii=data.begin();
215  ii!=data.end();ii++)
216  {
217  byte* data = ii->getData();
218  for(int i=ii->getSize(); i>0; i--, data++)
219  {
220  int val = int(int(*data) + fgauss01()*sigma);
221  if(val<0) *data = 0;
222  else if(val>255) *data = 255;
223  else *data = byte(val);
224  }
225  }
226  m_RefreshImage = true;
227 }
std::vector< ByteImage > data
Definition: Data.h:108
bool m_RefreshImage
Definition: Data.h:117
float fgauss01()
Definition: mathutil.h:53
unsigned char byte
Definition: simpletypes.h:4
void Dataset::calcMinMax ( )
inlineprotectedvirtual

Reimplemented from Sensor.

Definition at line 102 of file Data.h.

References Sensor::maxval, and Sensor::minval.

102  {
103  maxval = 255;
104  minval = 0;
105  }
float minval
overall minimum and maximum
Definition: Sensor.h:176
float maxval
Definition: Sensor.h:176
std::vector<float> Dataset::calcMValue ( int  x,
int  y 
) const
inlineprotectedvirtual

implementing virtual from class Sensor

Reimplemented from Sensor.

Definition at line 92 of file Data.h.

References data, and m_NChannels.

92  {
93  //vuLock l(*((vuMutex*)&writeMutex));
94  std::vector<float> mv(m_NChannels);
95  int cc = 0;
96  for(std::vector<float>::iterator cv = mv.begin();
97  cv != mv.end(); cv++, cc++) {
98  *cv = (float)data[cc].getPixel(x,y);
99  }
100  return mv;
101  }
std::vector< ByteImage > data
Definition: Data.h:108
int m_NChannels
Definition: Data.h:111
float Dataset::calcValue ( int  x,
int  y 
) const
inlineprotectedvirtual

implementing virtual from class Sensor

Implements Sensor.

Definition at line 85 of file Data.h.

References data, m_CurrImage, m_Dim1, and m_Dim2.

85  {
86  //vuLock l(*((vuMutex*)&writeMutex));
87  if((dword)x < (dword)m_Dim1 && (dword)y < (dword)m_Dim2)
88  return data[m_CurrImage].getPixel(x,y);
89  else return 0.0f;
90  }
std::vector< ByteImage > data
Definition: Data.h:108
int m_Dim2
Definition: Data.h:111
unsigned long dword
Definition: simpletypes.h:6
int m_Dim1
Definition: Data.h:111
int m_CurrImage
current image
Definition: Data.h:112
void Dataset::clear ( )

Definition at line 143 of file Data.cpp.

References data, DEFAULT_PPMM, m_CurrImage, m_Dim1, m_Dim2, m_Dim3, m_Filename, m_NChannels, m_Origin, m_ppmm, Sensor::performUpdate(), Sensor::setModified(), and Sensor::UPD_DATA.

Referenced by print().

144 {
145  m_Dim1 = m_Dim2 = m_Dim3 = 0;
146  m_NChannels = 0; m_CurrImage = 0;
148  data.clear();
149  data.resize(1);
150  m_Filename.clear();
151  m_Origin = 0.0f;
153  performUpdate();
154 }
std::vector< ByteImage > data
Definition: Data.h:108
int m_Dim2
Definition: Data.h:111
int m_Dim3
Definition: Data.h:111
Point2D m_Origin
Definition: Data.h:115
virtual bool performUpdate()
Definition: Sensor.cpp:123
std::string m_Filename
Definition: Data.h:114
int m_NChannels
Definition: Data.h:111
int m_Dim1
Definition: Data.h:111
int m_CurrImage
current image
Definition: Data.h:112
dword m_ppmm
Definition: Data.h:113
#define DEFAULT_PPMM
Definition: Data.h:16
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
Dataset & Dataset::copyData ( const Dataset rhs)

Definition at line 127 of file Data.cpp.

References data, m_CurrImage, m_Dim1, m_Dim2, m_Dim3, m_Filename, m_HalveBeyondSize, m_NChannels, m_ppmm, Sensor::performUpdate(), Sensor::setModified(), and Sensor::UPD_DATA.

Referenced by ~Dataset().

128 {
129  data = rhs.data;
130  m_CurrImage = 0;
131  m_Dim1 = data[0].getSizeX();
132  m_Dim2 = data[0].getSizeY();
133  m_Dim3 = 1;
134  m_NChannels = data.size();
135  m_ppmm = rhs.m_ppmm;
136  m_Filename = rhs.m_Filename;
139  performUpdate();
140  return *this;
141 }
std::vector< ByteImage > data
Definition: Data.h:108
int m_Dim2
Definition: Data.h:111
int m_Dim3
Definition: Data.h:111
virtual bool performUpdate()
Definition: Sensor.cpp:123
std::string m_Filename
Definition: Data.h:114
dword m_HalveBeyondSize
Definition: Data.h:118
int m_NChannels
Definition: Data.h:111
int m_Dim1
Definition: Data.h:111
int m_CurrImage
current image
Definition: Data.h:112
dword m_ppmm
Definition: Data.h:113
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
void Dataset::draw ( float  x = 0,
float  y = 0,
float  sx = 1.0f,
float  sy = 1.0f 
) const

Draw data set (using OpenGL)

Definition at line 113 of file Data.cpp.

References data, GLImage::draw(), m_GLImage, m_RefreshImage, GLImage::setImage(), and GLImage::unsetImage().

Referenced by ImageWindow::drawScene(), and ~Dataset().

114 {
115  if(!data.empty())
116  {
117  if(m_RefreshImage) {
120  m_RefreshImage = false;
121  }
122  m_GLImage.draw(x, y, sx, sy);
123  //drawImage(data,x,y,sx,sy);
124  }
125 }
std::vector< ByteImage > data
Definition: Data.h:108
void setImage(const Image< byte > &image)
Definition: glImage.h:27
void draw(float x, float y, float sx=1.f, float sy=1.f) const
Definition: glImage.h:85
void unsetImage()
Definition: glImage.h:72
bool m_RefreshImage
Definition: Data.h:117
GLImage m_GLImage
Definition: Data.h:116
void Dataset::drawImage ( const std::vector< Image< byte > > &  image,
float  x = 0,
float  y = 0,
float  sx = 1.0f,
float  sy = 1.0f 
)
static

Draw Image using glDrawPixels()

Definition at line 263 of file Data.cpp.

References interleave().

Referenced by getImage().

265 {
266  byte *buf = interleave(image);
267  glPixelZoom(sx, sy);
268  glRasterPos3f(x,y,0.0f);
269  glDrawPixels(image[0].getSizeX(),
270  image[0].getSizeY(),
271  GL_RGB,
272  GL_UNSIGNED_BYTE,
273  buf);
274  delete buf;
275 }
byte * interleave(const vector< Image< byte > > &img)
Definition: Data.cpp:241
unsigned char byte
Definition: simpletypes.h:4
void Dataset::drawImage ( const Image< byte > &  image,
float  x = 0,
float  y = 0,
float  sx = 1.0f,
float  sy = 1.0f 
)
static

Definition at line 229 of file Data.cpp.

References Image< T >::getData(), Image< T >::getSizeX(), and Image< T >::getSizeY().

231 {
232  glPixelZoom(sx, sy);
233  glRasterPos3f(x,y,0.0f);
234  glDrawPixels(image.getSizeX(),
235  image.getSizeY(),
236  GL_LUMINANCE,
237  GL_UNSIGNED_BYTE,
238  image.getData());
239 }
int getSizeX() const
Definition: Image.h:42
const T * getData() const
Definition: Image.h:39
int getSizeY() const
Definition: Image.h:43
int Dataset::getDim1Size ( ) const
inlinevirtual

the real dataset will override these

Reimplemented from Sensor.

Definition at line 44 of file Data.h.

References m_Dim1.

Referenced by ImageWindow::drawScene(), main(), ImageWindow::onKeyPress(), ImageWindow::onLeftMouseClick(), and ImageWindow::onRightMouseClick().

44 { return m_Dim1; }
int m_Dim1
Definition: Data.h:111
int Dataset::getDim2Size ( ) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 45 of file Data.h.

References m_Dim2.

Referenced by ImageWindow::drawScene(), main(), ImageWindow::onKeyPress(), ImageWindow::onLeftMouseClick(), and ImageWindow::onRightMouseClick().

45 { return m_Dim2; }
int m_Dim2
Definition: Data.h:111
int Dataset::getDim3Size ( ) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 46 of file Data.h.

References m_Dim3.

46 { return m_Dim3; }
int m_Dim3
Definition: Data.h:111
const std::string& Dataset::getFilename ( ) const
inline

Definition at line 75 of file Data.h.

References m_Filename.

75 { return m_Filename; }
std::string m_Filename
Definition: Data.h:114
dword Dataset::getHalveBeyondSize ( ) const
inline

Definition at line 81 of file Data.h.

References addNoise(), and m_HalveBeyondSize.

81 { return m_HalveBeyondSize; }
dword m_HalveBeyondSize
Definition: Data.h:118
const ByteImage& Dataset::getImage ( ) const
inline

Definition at line 54 of file Data.h.

References data, and m_CurrImage.

Referenced by ImageWindow::onKeyPress().

54 { return data.at(m_CurrImage); }
std::vector< ByteImage > data
Definition: Data.h:108
int m_CurrImage
current image
Definition: Data.h:112
ByteImage& Dataset::getImage ( )
inline

Definition at line 55 of file Data.h.

References data, and m_CurrImage.

55 { return data.at(m_CurrImage); }
std::vector< ByteImage > data
Definition: Data.h:108
int m_CurrImage
current image
Definition: Data.h:112
const ByteImage& Dataset::getImage ( int  index) const
inline

Definition at line 56 of file Data.h.

References data.

56 { return data.at(index); }
std::vector< ByteImage > data
Definition: Data.h:108
ByteImage& Dataset::getImage ( int  index)
inline

Definition at line 57 of file Data.h.

References data, drawImage(), and loadImage().

57 { return data.at(index); }
std::vector< ByteImage > data
Definition: Data.h:108
int Dataset::getNChannels ( ) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 47 of file Data.h.

References m_NChannels.

47 { return m_NChannels; }
int m_NChannels
Definition: Data.h:111
const Point2D& Dataset::getOrigin ( ) const
inline

Definition at line 72 of file Data.h.

References m_Origin.

72 { return m_Origin; }
Point2D m_Origin
Definition: Data.h:115
const Point2D& Dataset::getOSize ( ) const
inline

Definition at line 73 of file Data.h.

References m_OSize.

73 { return m_OSize; }
Point2D m_OSize
Definition: Data.h:115
dword Dataset::getPPMM ( ) const
inline

Definition at line 70 of file Data.h.

References m_ppmm.

70 { return m_ppmm; }
dword m_ppmm
Definition: Data.h:113
PropVec Dataset::getPropVec ( ) const
inline

Definition at line 76 of file Data.h.

References m_Dim1, and setPropScale().

Referenced by getPropVecMM().

77  { PropVec pv(0.f); return setPropScale(pv, (float)m_Dim1); }
int m_Dim1
Definition: Data.h:111
PropVec & setPropScale(PropVec &prop, float pscale)
Definition: PropVec.h:22
PropVec Dataset::getPropVecMM ( ) const
inline

Definition at line 78 of file Data.h.

References getPropVec(), m_ppmm, and scalePropVec().

79  { PropVec pv(getPropVec()); return scalePropVec(pv, 1.f/m_ppmm); }
PropVec & scalePropVec(PropVec &prop, float scale)
Definition: PropVec.h:85
dword m_ppmm
Definition: Data.h:113
PropVec getPropVec() const
Definition: Data.h:76
bool Dataset::initialized ( ) const
inline

Definition at line 52 of file Data.h.

References m_Dim1, and m_Dim2.

Referenced by ImageWindow::drawScene(), and operator bool().

52 { return m_Dim1 && m_Dim2; }
int m_Dim2
Definition: Data.h:111
int m_Dim1
Definition: Data.h:111
bool Dataset::load ( const char *  filename,
dword  ppmm = 0 
)

Load data set from file

Definition at line 62 of file Data.cpp.

References data, Image< T >::getSizeX(), Image< T >::getSizeY(), Image< T >::insert(), loadImage(), m_CurrImage, m_Dim1, m_Dim2, m_Dim3, m_Filename, m_HalveBeyondSize, m_NChannels, m_Origin, m_OSize, m_RefreshImage, Sensor::performUpdate(), Sensor::setModified(), setPPMM(), Image< T >::sum(), Sensor::UPD_DATA, writeMutex, Point2D::x, and Point2D::y.

Referenced by ImageWindow::changeSpecies(), Dataset(), and ~Dataset().

63 {
64  if(data.empty()) data.push_back(*(new ByteImage()));
65  vuLock l(writeMutex);
66  bool loaded = loadImage(data, filename);
67  if(loaded) {
68  m_Filename = filename;
69  m_Origin = 0.0f;
70  if(data[0].getSizeY()>3 && data[0].getSizeX()>3) {
71  ByteImage zimg(data[0].getSizeX()-2, data[0].getSizeY()-2,0);
72  int brd = (1<<6);
73  m_Origin = (float)brd;
74  for(vector< ByteImage >::iterator ii=data.begin();
75  ii!=data.end();ii++)
76  {
77  if((dword)ii->getSize() > m_HalveBeyondSize) {
78  *ii = ii->scaleBy(0.5);
79  ppmm /= 2;
80  cout << "reducing image" << endl;
81  }
82  ByteImage copimg(*ii);
83  copimg.insert(zimg, 1, 1);
84  double avgcol = copimg.sum()/
85  ((copimg.getSizeX()+copimg.getSizeY())*2-4);
86  ii->zeroPad(brd, byte(avgcol));
87  // make edge length even
88  dword nx = (ii->getSizeX()/2+1)*2;
89  dword ny = (ii->getSizeY()/2+1)*2;
90  ByteImage ni(nx, ny, byte(avgcol));
91  ni.insert(*ii);
92  *ii = ni;
93 // stringstream fname;
94 // fname << "bimage" << ii-data.begin() << ".ppm";
95 // if(ii->writePPM(fname.str())) cout << "ok." << endl;
96  }
97  }
98  m_OSize.x = (float)data[0].getSizeX();
99  m_OSize.y = (float)data[0].getSizeY();
100  m_CurrImage = 0;
101  m_Dim1 = data[0].getSizeX();
102  m_Dim2 = data[0].getSizeY();
103  m_Dim3 = 1;
104  m_RefreshImage = true;
105  m_NChannels = data.size();
106  setPPMM(ppmm);
108  performUpdate();
109  return true;
110  } else return false;
111 }
void setPPMM(dword ppmm)
Definition: Data.h:71
std::vector< ByteImage > data
Definition: Data.h:108
int m_Dim2
Definition: Data.h:111
static bool loadImage(std::vector< Image< byte > > &image, const char *filename)
Definition: Data.cpp:159
int m_Dim3
Definition: Data.h:111
float y
Definition: Point.h:224
bool m_RefreshImage
Definition: Data.h:117
Point2D m_Origin
Definition: Data.h:115
virtual bool performUpdate()
Definition: Sensor.cpp:123
Point2D m_OSize
Definition: Data.h:115
std::string m_Filename
Definition: Data.h:114
dword m_HalveBeyondSize
Definition: Data.h:118
int m_NChannels
Definition: Data.h:111
unsigned long dword
Definition: simpletypes.h:6
unsigned char byte
Definition: simpletypes.h:4
int m_Dim1
Definition: Data.h:111
vuMutex writeMutex
Definition: Data.h:68
int m_CurrImage
current image
Definition: Data.h:112
float x
Definition: Point.h:224
void setModified(dword mask=UPD_ALL)
Definition: Sensor.h:110
bool Dataset::loadImage ( std::vector< Image< byte > > &  image,
const char *  filename 
)
static

Load an Image<byte>

Definition at line 159 of file Data.cpp.

References copyFXImage2Image(), and NULL.

Referenced by getImage(), and load().

159  {
160  FXString ext=FXPath::extension(file);
161  FXImage *img=NULL;
162  FXApp *app = FXApp::instance(); //getApp()
163 
164  if(comparecase(ext,"bmp")==0){
165  img=new FXBMPImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
166  }
167  else if(comparecase(ext,"gif")==0){
168  img=new FXGIFImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
169  }
170  else if(comparecase(ext,"tga")==0){
171  img=new FXTGAImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
172  }
173 #ifdef HAVE_PNG_H
174  else if(comparecase(ext,"png")==0){
175  img=new FXPNGImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
176  }
177 #endif
178 #ifdef HAVE_JPEG_H
179  else if(comparecase(ext,"jpg")==0){
180  img=new FXJPGImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
181  }
182 #endif
183 #ifdef HAVE_TIFF_H
184  else if(comparecase(ext,"tif")==0 || comparecase(ext,"tiff")==0){
185  img=new FXTIFImage(app,NULL,IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP);
186  }
187 #endif
188  bool load_ok = false;
189  if(img!=NULL) {
190  // Load it
191  FXFileStream stream;
192  if(stream.open(file,FXStreamLoad)){
193  //app->beginWaitCursor();
194  load_ok = img->loadPixels(stream);
195  if(load_ok) {
196  img->create();
197  //app->endWaitCursor();
198  //img->mirror(false, true);
199  copyFXImage2Image(image, *img);
200  }
201  stream.close();
202  }
203  delete img;
204  }
205  //note: modal error message causes deadlock on Brain::m_DataMutex
206  //between Brain::loadData and Brain::drawAllModels
207  //if(!load_ok)
208  // FXMessageBox::error(/*this app->getRootWindow()*/ app,MBOX_OK,"Error Loading Image","Unsupported type: %s",ext.text());
209  return load_ok;
210 }
#define NULL
Definition: simpletypes.h:9
static void copyFXImage2Image(vector< Image< byte > > &dimg, const FXImage &img)
Definition: Data.cpp:280
Dataset::operator bool ( ) const
inline

Definition at line 53 of file Data.h.

References initialized().

53 { return initialized(); }
bool initialized() const
Definition: Data.h:52
std::ostream& Dataset::print ( std::ostream &  os) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 48 of file Data.h.

References clear().

49  { return os; } //don't print to model file
void Dataset::setHalveBeyondSize ( dword  hbs = 0xffffffff)
inline

Definition at line 80 of file Data.h.

References m_HalveBeyondSize.

80 { m_HalveBeyondSize = hbs; }
dword m_HalveBeyondSize
Definition: Data.h:118
void Dataset::setPPMM ( dword  ppmm)
inline

Definition at line 71 of file Data.h.

References DEFAULT_PPMM, and m_ppmm.

Referenced by load().

71 { m_ppmm = ppmm ? ppmm : DEFAULT_PPMM; }
dword m_ppmm
Definition: Data.h:113
#define DEFAULT_PPMM
Definition: Data.h:16

Member Data Documentation

std::vector<ByteImage> Dataset::data
protected

The data as one dimensional array. If more than one channel is used data will be organized as vector<ByteImage>.

Definition at line 108 of file Data.h.

Referenced by addNoise(), calcMValue(), calcValue(), clear(), copyData(), draw(), getImage(), load(), and makeNoiseImage().

int Dataset::m_CurrImage
protected

current image

Definition at line 112 of file Data.h.

Referenced by calcValue(), clear(), copyData(), getImage(), and load().

int Dataset::m_Dim1
protected

Dimensions in X, Y, and Z direction + number of channels

Definition at line 111 of file Data.h.

Referenced by calcValue(), clear(), copyData(), getDim1Size(), getPropVec(), initialized(), and load().

int Dataset::m_Dim2
protected

Definition at line 111 of file Data.h.

Referenced by calcValue(), clear(), copyData(), getDim2Size(), initialized(), and load().

int Dataset::m_Dim3
protected

Definition at line 111 of file Data.h.

Referenced by clear(), copyData(), getDim3Size(), and load().

std::string Dataset::m_Filename
protected

Definition at line 114 of file Data.h.

Referenced by clear(), copyData(), getFilename(), and load().

GLImage Dataset::m_GLImage
mutableprotected

Definition at line 116 of file Data.h.

Referenced by draw().

dword Dataset::m_HalveBeyondSize
protected

Definition at line 118 of file Data.h.

Referenced by copyData(), getHalveBeyondSize(), load(), and setHalveBeyondSize().

int Dataset::m_NChannels
protected

Definition at line 111 of file Data.h.

Referenced by calcMValue(), clear(), copyData(), getNChannels(), and load().

Point2D Dataset::m_Origin
protected

Definition at line 115 of file Data.h.

Referenced by clear(), getOrigin(), and load().

Point2D Dataset::m_OSize
protected

Definition at line 115 of file Data.h.

Referenced by getOSize(), and load().

dword Dataset::m_ppmm
protected

Definition at line 113 of file Data.h.

Referenced by clear(), copyData(), getPPMM(), getPropVecMM(), and setPPMM().

bool Dataset::m_RefreshImage
mutableprotected

Definition at line 117 of file Data.h.

Referenced by addNoise(), draw(), and load().

vuMutex Dataset::writeMutex

Definition at line 68 of file Data.h.

Referenced by load().


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