Version 8.9.0
 
Loading...
Searching...
No Matches
ImageBuilder.h
1/******************************************************************************
2 * Copyright (c) 2012-2017 All Rights Reserved, http://www.evocortex.com *
3 * Evocortex GmbH *
4 * Emilienstr. 1 *
5 * 90489 Nuremberg *
6 * Germany *
7 * *
8 * Contributors: *
9 * Initial version for Linux 64-Bit platform supported by Fraunhofer IPA, *
10 * http://www.ipa.fraunhofer.de *
11 *****************************************************************************/
12
13#ifndef OPTRISIMAGEBUILDER_H
14#define OPTRISIMAGEBUILDER_H
15
16#include <cstddef>
17#include "irdirectsdk_defs.h"
18
19namespace evo
20{
21
26{
27 float t;
28 int u1;
29 int v1;
30 int u2;
31 int v2;
32};
33
34enum EnumOptrisColoringPalette{eAlarmBlue = 1,
35 eAlarmBlueHi = 2,
36 eGrayBW = 3,
37 eGrayWB = 4,
38 eAlarmGreen = 5,
39 eIron = 6,
40 eIronHi = 7,
41 eMedical = 8,
42 eRainbow = 9,
43 eRainbowHi = 10,
44 eAlarmRed = 11};
45
53enum EnumOptrisPaletteScalingMethod{eManual = 1,
54 eMinMax = 2,
55 eSigma1 = 3,
56 eSigma3 = 4};
57
58typedef unsigned char (*paletteTable)[3];
59
65class __IRDIRECTSDK_API__ ImageBuilder
66{
67
68public:
69
75 ImageBuilder(bool alignStride=true, short decimalPlaces = 1);
76
81
88 void setData(unsigned int width, unsigned int height, const unsigned short* data);
89
94 unsigned int getWidth() const;
95
100 unsigned int getHeight() const;
101
107 float getTemperatureAt(int index) const;
108
115 float getTemperatureAt(int u, int v) const;
116
125 float getMeanTemperature(unsigned int u1, unsigned int v1, unsigned int u2, unsigned int v2);
126
133 void getMinMaxRegion(unsigned int radius, ExtremalRegion* minRegion, ExtremalRegion* maxRegion);
134
140 void setManualTemperatureRange(float min, float max);
141
146 float getIsothermalMin() const;
147
152 float getIsothermalMax() const;
153
158 void setPaletteScalingMethod(EnumOptrisPaletteScalingMethod method);
159
164 EnumOptrisPaletteScalingMethod getPaletteScalingMethod() const;
165
170 unsigned int getStride(void) const;
171
176 void setPalette(EnumOptrisColoringPalette palette);
177
182 EnumOptrisColoringPalette getPalette() const;
183
188 void getPaletteTable(paletteTable& table) const;
189
194 void fillPaletteLookup(unsigned int lut[65536]);
195
201 void convertTemperatureToPaletteImage(unsigned char* dst, bool ignoreStride=false);
202
208 void convertTemperatureToPaletteImage(unsigned int lut[65536], unsigned char* dst);
209
215 void getPaletteBar(unsigned int w, unsigned int h, unsigned char* &img) const;
216
224 void calcHistogram(unsigned int* hist, unsigned int histsize, int tMin, int tMax) const;
225
233 void drawCrosshair(unsigned char* img, unsigned int x, unsigned int y, unsigned char rgb[3] = NULL) const;
234
242 void yuv422torgb24(const unsigned char* src, unsigned char* dst, unsigned int w, unsigned int h) const;
243
252 void convert2PPM(unsigned char* &ppm, unsigned int* size, unsigned char* buffer, unsigned int width, unsigned int height) const;
253
262 int serializePPM(const char* filename, unsigned char* buffer, unsigned int width, unsigned int height) const;
263
271 int readPPM3(const char* filename, unsigned char** buffer, unsigned int* width, unsigned int* height);
272
273private:
274
278 void calculateIntegralImage();
279
283 void calcMinMaxScalingFactor();
284
289 void calcSigmaScalingFactor(float sigma);
290
294 unsigned short* _data;
295
296 //Conversion divisor
297 float _thermalDecimalPlaceDivisor;
298
299 //Conversion offset
300 float _thermalOffset;
301
305 unsigned long* _integral;
306
310 EnumOptrisPaletteScalingMethod _scalingMethod;
311
315 unsigned short _min;
316
320 unsigned short _max;
321
325 unsigned int _width;
326
330 unsigned int _height;
331
335 unsigned int _stride;
336
340 unsigned int _size;
341
345 EnumOptrisColoringPalette _palette;
346
350 bool _alignStride;
351
355 bool _integralIsDirty;
356
357};
358
359}
360
361#endif //OPTRISIMAGEBUILDER_H
Image creation module for displaying purposes.
Definition: ImageBuilder.h:66
~ImageBuilder()
Destructor.
float getMeanTemperature(unsigned int u1, unsigned int v1, unsigned int u2, unsigned int v2)
Get mean temperature of rectangular measuring field.
void convertTemperatureToPaletteImage(unsigned char *dst, bool ignoreStride=false)
Image conversion to rgb (bgr on windows)
float getIsothermalMin() const
Get minimum temperature used to scale image.
void setData(unsigned int width, unsigned int height, const unsigned short *data)
Set new data.
EnumOptrisColoringPalette getPalette() const
Get palette for color conversion return coloring palette.
void getPaletteTable(paletteTable &table) const
Get palette table for color conversion.
void setManualTemperatureRange(float min, float max)
Set temperature range for manual scaling method.
float getTemperatureAt(int index) const
Get temperature from last acquired image at specified image index.
void setPalette(EnumOptrisColoringPalette palette)
Set palette for color conversion.
void calcHistogram(unsigned int *hist, unsigned int histsize, int tMin, int tMax) const
calculate histogram
void convertTemperatureToPaletteImage(unsigned int lut[65536], unsigned char *dst)
Image conversion to rgb with lookup table.
void drawCrosshair(unsigned char *img, unsigned int x, unsigned int y, unsigned char rgb[3]=NULL) const
Draw crosshair to the center of image.
EnumOptrisPaletteScalingMethod getPaletteScalingMethod() const
Accessor for activated color conversion mode.
void convert2PPM(unsigned char *&ppm, unsigned int *size, unsigned char *buffer, unsigned int width, unsigned int height) const
Convert palette image to ppm format.
void getMinMaxRegion(unsigned int radius, ExtremalRegion *minRegion, ExtremalRegion *maxRegion)
Get region of minimum/maximum temperature with given radius.
void setPaletteScalingMethod(EnumOptrisPaletteScalingMethod method)
Scaling method of color conversion.
void fillPaletteLookup(unsigned int lut[65536])
Fill lookup table for false color conversion.
unsigned int getWidth() const
Get image width.
void yuv422torgb24(const unsigned char *src, unsigned char *dst, unsigned int w, unsigned int h) const
Convert YUV422 image to RGB format (8-Bit per channel)
void getPaletteBar(unsigned int w, unsigned int h, unsigned char *&img) const
int serializePPM(const char *filename, unsigned char *buffer, unsigned int width, unsigned int height) const
Serialize data to PPM-format.
int readPPM3(const char *filename, unsigned char **buffer, unsigned int *width, unsigned int *height)
Read PPM (P3) format.
float getIsothermalMax() const
Get maximum temperature used to scale image.
unsigned int getHeight() const
Get image height.
unsigned int getStride(void) const
If memory alignment is needed, this class provides a stride parameter configured with setSize(....
float getTemperatureAt(int u, int v) const
Get temperature from last acquired image at specified image coordinates.
ImageBuilder(bool alignStride=true, short decimalPlaces=1)
Standard constructor.
Rectangular area having extremal temperature, i.e., minimum or maximum temperature in a certain image...
Definition: ImageBuilder.h:26
int u2
right-most column index
Definition: ImageBuilder.h:30
float t
mean temperature
Definition: ImageBuilder.h:27
int v2
upper row index
Definition: ImageBuilder.h:31
int v1
lower row index
Definition: ImageBuilder.h:29
int u1
left-most column index
Definition: ImageBuilder.h:28