104 #ifdef PIC_ENABLE_OPEN_EXR 271 void setRand(
unsigned int seed);
329 void applyFunctionParam(
float(*func)(
float, std::vector<float>&), std::vector<float> ¶m);
402 float *
getMomentsVal(
int x0,
int y0,
int radius,
float *ret);
475 float *
getColorSamples(
float *samples,
int &nSamples,
float percentage);
514 return (x > -1) && (x < width) && (y > -1) && (y <
height) &&
535 bool *
convertToMask(
float *color,
float threshold,
bool cmp,
bool *mask);
557 void clamp(
float a,
float b);
619 float *
getLL(
float x,
float y,
float z)
621 float xf = 1.0f - ((atan2f(z, -x) *
C_INV_PI) * 0.5f + 0.5f);
684 x = ind - (y *
width);
878 float *tmp =
new float[size_i];
879 memcpy(tmp,
data,
sizeof(
float) * size_i);
880 std::sort(tmp, tmp + size_i);
913 #ifdef PIC_ENABLE_OPEN_EXR 939 width = imgIn->width;
953 #ifdef PIC_ENABLE_OPEN_EXR 986 this->notOwned =
true;
1023 #ifdef PIC_ENABLE_OPEN_EXR 1033 printf(
"Image::Allocate: not a valid image to be allocated.\n");
1038 if(this->width > 0 && this->height > 0 && this->channels > 0 &&
1039 this->frames > 0 &&
data != NULL) {
1041 printf(
"Image::Allocate: already allocated image.\n");
1048 this->width =
width;
1050 this->notOwned =
false;
1062 this->widthf = float(
width);
1063 this->width1f = float(
width - 1);
1064 this->heightf = float(
height);
1065 this->height1f = float(
height - 1);
1067 this->framesf = float(
frames);
1068 this->frames1f = float(
frames -1);
1090 allocate(imgIn->width, imgIn->height, imgIn->channels, imgIn->frames);
1098 memcpy(
data, imgIn->data,
size() *
sizeof(
float));
1103 int size_i =
size();
1105 #pragma omp parallel for 1106 for(
int i = 0; i < size_i; i++) {
1113 int size_i =
size();
1115 #pragma omp parallel for 1116 for(
int i = 0; i < size_i; i++) {
1117 float val =
data[i];
1131 bool ret = (
width == img->width) &&
1132 (
height == img->height) &&
1133 (
frames == img->frames) &&
1140 printf(
"\nImage::isSimilarType: ERROR The two compared images are not similar.\n");
1163 int half_h =
height >> 1;
1165 #pragma omp parallel for 1166 for(
int i = 0; i <
height; i++) {
1167 float angle =
C_PI * float(i - half_h) / float(
height);
1168 float cosAng =
MAX(cosf(angle), 0.0f);
1170 for(
int j = 0; j <
width; j++) {
1171 float *tmp_data = (*this)(j, i);
1173 for(
int k = 0; k <
channels; k++) {
1174 tmp_data[k] *= cosAng;
1186 int size_i =
size();
1188 #pragma omp parallel for 1189 for(
int i = 0; i < size_i; i++) {
1200 int size_i =
size();
1202 #pragma omp parallel for 1203 for(
int i = 0; i < size_i; i++) {
1222 int size_i = box->
Size();
1223 float *dataTMP =
new float[size_i];
1225 for(
int ch = 0; ch <
channels; ch++) {
1227 for(
int k = box->z0; k < box->z1; k++) {
1228 for(
int j = box->y0; j < box->y1; j++) {
1229 for(
int i = box->x0; i < box->x1; i++) {
1230 dataTMP[counter] = (*this)(i, j, k)[ch];
1236 std::sort(dataTMP, dataTMP + size_i);
1238 int size_i_t = size_i - 1;
1239 int index_r = ch << 1;
1244 float size_i_t_f = float(size_i_t);
1246 index_f = percentile * size_i_t_f;
1247 index =
CLAMPi(
int(index_f), 0, size_i_t);
1248 ret[index_r ] = dataTMP[index];
1250 index_f = (1.0f - percentile) * size_i_t_f;
1251 index =
CLAMPi(
int(index_f), 0, size_i_t);
1252 ret[index_r + 1] = dataTMP[index];
1272 if(percentile <= 0.5f) {
1276 float percentile_low = 1.0f - percentile;
1279 float min_val = values[0];
1280 float max_val = values[1];
1282 if(min_val > 0.0f) {
1283 return max_val / min_val;
1285 if(percentile > 0.5f) {
1294 float *min_val_v =
getMinVal(NULL, NULL);
1295 float *max_val_v =
getMaxVal(NULL, NULL);
1301 if(min_val <= 0.0f) {
1306 if(min_val != max_val) {
1307 if(max_val > min_val) {
1308 ret = max_val / min_val;
1326 if(img == NULL || weight == NULL) {
1330 if( (weight->channels != 1) &&
1331 (weight->channels != img->channels)) {
1337 #pragma omp parallel for 1338 for(
int ind = 0; ind <
size; ind++) {
1341 int indx_w = ind * weight->channels;
1343 float w0 = weight->data[indx_w];
1344 float w1 = 1.0f - w0;
1346 for(
int j = 0; j <
channels; j++) {
1349 data[indx] =
data[indx] * w0 + img->data[indx] * w1;
1362 #pragma omp parallel for 1364 for(
int i = 0; i < n; i++) {
1365 data[i] =
data[i] > img->data[i] ? img->data[i] :
data[i];
1377 #pragma omp parallel for 1378 for(
int i = 0; i < n; i++) {
1379 data[i] =
data[i] < img->data[i] ? img->data[i] :
data[i];
1398 std::mt19937 m(seed);
1401 for(
int i = 0; i < n; i++) {
1402 data[i] = float(m()) / 4294967295.0f;
1420 for(
int l = 0; l <
channels; l++) {
1424 for(
int k = box->z0; k < box->z1; k++) {
1425 for(
int j = box->y0; j < box->y1; j++) {
1426 for(
int i = box->x0; i < box->x1; i++) {
1427 float *tmp_data = (*this)(i, j, k);
1429 for(
int l = 0; l <
channels; l++) {
1430 ret[l] = ret[l] < tmp_data[l] ? tmp_data[l] : ret[l];
1453 for(
int l = 0; l <
channels; l++) {
1457 for(
int k = box->z0; k < box->z1; k++) {
1458 for(
int j = box->y0; j < box->y1; j++) {
1459 for(
int i = box->x0; i < box->x1; i++) {
1460 float *tmp_data = (*this)(i, j, k);
1462 for(
int l = 0; l <
channels; l++) {
1463 ret[l] = ret[l] > tmp_data[l] ? tmp_data[l] : ret[l];
1488 for(
int k = box->z0; k < box->z1; k++) {
1489 for(
int j = box->y0; j < box->y1; j++) {
1490 for(
int i = box->x0; i < box->x1; i++) {
1491 float *tmp_data = (*this)(i, j, k);
1513 float totf = float(box->Size());
1529 ret =
new float[channels_2];
1534 for(
int j = -radius; j <= radius; j++) {
1537 for(
int i = -radius; i <= radius; i++) {
1540 float *tmp_data = (*this)(x, y);
1542 for(
int l = 0; l < channels_2; l += 2) {
1543 ret[l ] += j * tmp_data[l];
1544 ret[l + 1] += i * tmp_data[l];
1564 bool bDeleteMeanVal =
false;
1566 if(meanVal == NULL) {
1568 bDeleteMeanVal =
true;
1577 for(
int k = box->z0; k < box->z1; k++) {
1578 for(
int j = box->y0; j < box->y1; j++) {
1579 for(
int i = box->x0; i < box->x1; i++) {
1580 float *tmp_data = (*this)(i, j, k);
1582 for(
int l = 0; l <
channels; l++) {
1583 float tmp = tmp_data[l] - meanVal[l];
1584 ret[l] += tmp * tmp;
1590 float totf = float(box->Size() - 1);
1594 if(bDeleteMeanVal) {
1612 bool bMeanValAllocated =
false;
1614 if(meanVal == NULL) {
1616 bMeanValAllocated =
true;
1627 for(
int k = box->z0; k < box->z1; k++) {
1628 for(
int j = box->y0; j < box->y1; j++) {
1629 for(
int i = box->x0; i < box->x1; i++) {
1630 float *tmp_data = (*this)(i, j, k);
1632 for(
int l = 0; l <
channels; l++) {
1633 float tmp1 = (tmp_data[l] - meanVal[l]);
1635 for(
int m = 0; m <
channels; m++) {
1636 float tmp2 = (tmp_data[m] - meanVal[m]);
1638 ret[l *
channels + m] += tmp1 * tmp2;
1645 float totf = float(box->Size() - 1);
1649 if(bMeanValAllocated) {
1672 for(
int k = box->z0; k < box->z1; k++) {
1673 for(
int j = box->y0; j < box->y1; j++) {
1674 for(
int i = box->x0; i < box->x1; i++) {
1675 float *tmp_data = (*this)(i, j, k);
1677 for(
int l = 0; l <
channels; l++) {
1678 ret[l] += logf(tmp_data[l] + 1e-6f);
1684 float totf = float(box->Size());
1686 for(
int l = 0; l <
channels; l++) {
1687 ret[l] = expf(ret[l] / totf);
1695 if((mask == NULL) || (
width < 1) || (
height < 1)) {
1705 #pragma omp parallel for 1706 for(
int i = 0; i <
size; i++) {
1707 data[i] = mask[i] ? 1.0f : 0.0f;
1712 bool cmp =
true,
bool *mask = NULL)
1718 bool bColorAllocated =
false;
1721 bColorAllocated =
true;
1733 float tmpThreshold = threshold * float(
channels);
1735 #pragma omp parallel for 1736 for(
int i = 0; i < n; i++) {
1741 for(
int k = 0; k <
channels; k++) {
1742 val += fabsf(
data[ind + k] - color[k]);
1745 bool bMask = val > tmpThreshold;
1746 mask[i] = cmp ? bMask : !bMask;
1756 if(bColorAllocated) {
1772 bool bReturn =
false;
1778 float *dataReader = NULL;
1783 #ifdef PIC_ENABLE_OPEN_EXR 1804 #ifdef PIC_ENABLE_OPEN_EXR 1807 #ifndef PIC_DISABLE_TINY_EXR 1839 unsigned char *dataReader = NULL;
1840 unsigned char *tmp = NULL;
1897 float *tmpFloat = NULL;
1907 if(tmpConv != NULL) {
1925 int writerCounter = 0)
1937 float *dataWriter = NULL;
1939 if((writerCounter > 0) && (writerCounter <
frames)) {
1961 #ifdef PIC_ENABLE_OPEN_EXR 1964 #ifndef PIC_DISABLE_TINY_EXR 1986 float *dataWriter = NULL;
1988 if((writerCounter > 0) && (writerCounter <
frames)) {
2051 if(img->isValid()) {
2052 allocate(img->width, img->height, img->channels, img->frames);
2075 float percentage = 1.0f)
2077 percentage =
CLAMPi(percentage, 0.0f, 1.0f);
2080 nSamples = int(ceilf(
float(nTot) * percentage));
2082 if(samples == NULL) {
2083 samples =
new float[nSamples *
channels];
2088 if(nSamples < nTot) {
2089 shift = nTot / nSamples;
2092 for(
int i = 0; i < nSamples; i++) {
2094 int index_d = index * shift;
2096 for(
int j = 0; j <
channels; j++) {
2097 samples[index + j] =
data[index_d + j];
2123 return Image(out,
false);
2131 if((
nPixels() == a.nPixels()) && (a.channels == 1)) {
2142 return Image(out,
false);
2154 return Image(out,
false);
2162 if((
nPixels() == a.nPixels()) && (a.channels == 1)) {
2172 return Image(out,
false);
2184 return Image(out,
false);
2192 if((
nPixels() == a.nPixels()) && (a.channels == 1)) {
2202 return Image(out,
false);
2214 return Image(out,
false);
2222 if((
nPixels() == a.nPixels()) && (a.channels == 1)) {
2232 return Image(out,
false);
static void rotate90CCW(T *buffer, int &width, int &height, int channels)
rotate90CCW rotates an image 90 CCW
Definition: buffer.hpp:508
static T * add(T *buffer, int n, T value)
add peforms addition
Definition: buffer.hpp:84
float * getCovMtxVal(float *meanVal, BBox *box, float *ret)
getCovMtxVal computes the convariance matrix for the current Image.
PIC_INLINE bool WriteTMP(std::string nameFile, float *data, int &width, int &height, int &channels, int &frames, bool bHeader=true)
WriteTMP writes a dump temp file.
Definition: tmp.hpp:101
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
void reverseAddress(int ind, int &x, int &y)
reverseAddress computes (x, y) given a memory address
Definition: image.hpp:680
void operator*=(const float &a)
operator *=
static T getMax(T *data, int size, int &ind)
getMax
Definition: array.hpp:516
void allocate(int width, int height, int channels, int frames)
allocate allocates memory for the pixel buffer.
void assign(const Image *imgIn)
assign
int size() const
size computes the number of values.
Definition: image.hpp:481
Image operator+(const float &a) const
operator +
static T * sub(T *buffer, int n, T value)
sub
Definition: buffer.hpp:227
static T * mul(T *buffer, int n, T value)
mul multiplies a constant value
Definition: buffer.hpp:148
~Image()
Image destructor. This deallocates: data, dataUC, and dataRGBE.
float * operator()(int x, int y, int t)
operator () returns a pointer to a pixel at (x, y, t)
Definition: image.hpp:577
void flipVH()
flipVH flips vertically and horizontally the current image.
Definition: image.hpp:229
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
void setZero()
setZero sets data to 0.0f.
int channels
Definition: image.hpp:80
void clamp(float a, float b)
clamp set data values in the range [a,b]
float * sort()
sort
Definition: image.hpp:871
int alpha
Definition: image.hpp:80
float * getMeanVal(BBox *box, float *ret)
getMeanVal computes the mean for the current Image.
void getNormalizedCoords(int x, int y, float &nx, float &ny)
getNormalizedCoords computes normalized coordinates (nx, ny) of (x, y).
Definition: image.hpp:638
PIC_INLINE unsigned char * ReadPGM(std::string nameFile, unsigned char *data, int &width, int &height, int &channels)
ReadPGM reads an .ppm file.
Definition: pgm.hpp:37
bool isSimilarType(const Image *img)
isSimilarType checks if the current image is similar to img; i.e. if they have the same width...
void scaleCosine()
scaleCosine multiplies the current image by the vertical cosine assuming a longitude-latitude image...
void minimum(Image *img)
minimum is the minimum operator for Image.
PIC_INLINE bool WriteHDR(std::string nameFile, float *data, int width, int height, int channels, float appliedExposure=1.0f, bool bRLE=true)
WriteHDR writes a .hdr/.pic file.
Definition: hdr.hpp:288
float channelsf
Definition: image.hpp:84
static T * mulS(T *bufferOut, T *bufferIn, int n, int channels)
mulS
Definition: buffer.hpp:204
bool flippedEXR
Definition: image.hpp:70
void setBox(int x0, int x1, int y0, int y1, int z0, int z1, int width, int height, int frames)
setBox sets a BBox up.
Definition: bbox.hpp:129
float * getSumVal(BBox *box, float *ret)
getSumVal sums values for the current Image.
const float C_PI
Definition: math.hpp:50
std::string nameFile
Definition: image.hpp:86
Image operator/(const float &a) const
operator /
Image operator-(const float &a) const
operator -
void allocateSimilarTo(Image *img)
allocateSimilarTo allocate an Image with similar size of the passed by.
float getDynamicRange(bool bRobust, float percentile)
getDynamicRange computes the dynamic range of the image.
PIC_INLINE bool isinf(T value)
isinf is it a Inf value?
Definition: math.hpp:103
int frames
Definition: image.hpp:80
float heightf
Definition: image.hpp:84
float framesf
Definition: image.hpp:84
bool getFlippedEXR()
getFlippedEXR returns the flippedEXR flag.
Definition: image.hpp:541
T * delete_vec_s(T *data)
delete_vec_s
Definition: std_util.hpp:138
float * getMedVal(BBox *box, float *ret)
getPercentileVal computes the median value value given a percentile.
PIC_INLINE unsigned char * ReadSTB(std::string nameFile, int &width, int &height, int &channels)
ReadSTB.
Definition: stb.hpp:57
LDR_type typeLoad
Definition: image.hpp:76
int getAddress(int x, int y, int t)
getAddress calculates a memory address from (x, y, t)
Definition: image.hpp:665
static void findSimple(T *data, int nData, bool(*func)(float), IntCoord &ret, int stride=1)
findSimple collects coordinates of data which satisfies a bool function func.
Definition: indexed_array.hpp:80
PIC_INLINE bool WriteEXR(std::string nameFile, float *data, int width, int height, int channels=3)
WriteEXR.
Definition: exr_tiny.hpp:95
LDR_type
The LDR_type enum.
Definition: dynamic_range.hpp:29
float * operator()(float x, float y)
operator () returns a pointer to a pixel at (x, y) with normalized coordinates (values in [0...
Definition: image.hpp:603
void flipV()
FlipV flips vertically the current image.
Definition: image.hpp:212
void maximum(Image *img)
maximum is the maximum operator for Image.
float * getMinVal(BBox *box, float *ret)
getMinVal computes the minimum value for the current Image.
static void rotate90CW(T *buffer, int &width, int &height, int channels)
rotate90CW rotates an image 90 CW
Definition: buffer.hpp:447
float * getLogMeanVal(BBox *box, float *ret)
getLogMeanVal computes the log mean for the current Image.
int getAddress(int x, int y)
getAddress calculates a memory address from (x, y)
Definition: image.hpp:650
static T * divS(T *bufferOut, T *bufferIn, int n, int channels)
divS
Definition: buffer.hpp:358
static void flipV(T *buffer, int width, int height, int channels, int frames)
flipV flips an image vertically
Definition: buffer.hpp:414
void operator-=(const float &a)
operator -=
static T * div(T *buffer, int n, T value)
div divides by a constant value
Definition: buffer.hpp:303
unsigned char * dataUC
dataUC is a buffer for rendering 8-bit images.
Definition: image.hpp:96
static bool bFuncNotNeg(T val)
bFuncNotNeg
Definition: indexed_array.hpp:48
bool notOwned
Definition: image.hpp:72
int Size()
Size computes the number of pixels in a bounding box.
Definition: bbox.hpp:112
static T min(T *data, IntCoord &coord)
min computes the min value.
Definition: indexed_array.hpp:136
Image operator*(const float &a) const
operator *
int nPixels() const
nPixels computes the number of pixels.
Definition: image.hpp:499
PIC_INLINE bool WriteVOL(std::string nameFile, float *data, int width, int height, int depth, int channels=3)
WriteVOL.
Definition: vol.hpp:119
float exposure
Definition: image.hpp:79
bool readEXIF(std::string name, EXIFInfo &info)
readEXIF
Definition: exif.hpp:250
PIC_INLINE bool isnan(T value)
isnan is it a NaN?
Definition: math.hpp:93
std::vector< int > IntCoord
IntCoord.
Definition: indexed_array.hpp:30
PIC_INLINE bool WritePGM(std::string nameFile, const unsigned char *data, int width, int height, int channels, bool bAscii=false)
WritePGM writes an .ppm file.
Definition: pgm.hpp:114
void blend(Image *img, Image *weight)
blend
bool * convertToMask(float *color, float threshold, bool cmp, bool *mask)
convertToMask converts an Image into a boolean mask.
BBox fullBox
Definition: image.hpp:74
void allocateAux()
allocateAux computes extra information after allocation; e.g. strides.
int xstride
Definition: image.hpp:82
float * getLL(float x, float y, float z)
getLL returns a pointer to a pixel given a normalized direction and assuming longituted-latitude mapp...
Definition: image.hpp:619
Image()
the basic construct of an Image
int depth
Definition: image.hpp:80
PIC_INLINE float * ReadEXR(std::string nameFile, float *data, int &width, int &height, int &channels)
Definition: exr_tiny.hpp:33
float height1f
Definition: image.hpp:84
#define PIC_INLINE
Definition: base.hpp:33
PIC_INLINE bool WritePFM(std::string nameFile, float *data, int width, int height, int channels=3)
WritePFM writes an HDR image in the portable float map format into a file.
Definition: pfm.hpp:148
void release()
release frees allocated buffers.
float widthf
Definition: image.hpp:84
void rotate90CW()
rotate90CW rotates 90 degrees clockwise the current image.
Definition: image.hpp:247
PIC_INLINE unsigned char * ReadBMP(std::string nameFile, unsigned char *data, int &width, int &height, int &channels)
ReadBMP reads an image as .bmp file.
Definition: bmp.hpp:94
static T getMin(T *data, int size, int &ind)
getMin
Definition: array.hpp:542
void applyFunction(float(*func)(float))
applyFunction is an operator that applies an input function to all values in data.
float * operator()(int x, int y)
operator () returns a pointer to a pixel at (x, y)
Definition: image.hpp:590
void applyFunctionParam(float(*func)(float, std::vector< float > &), std::vector< float > ¶m)
applyFunctionParam
PIC_INLINE bool WritePPM(std::string nameFile, const unsigned char *data, int width, int height, int channels)
WritePPM writes an .ppm file.
Definition: ppm.hpp:126
void setNULL()
setNULL sets buffers values to NULL.
PIC_INLINE LABEL_IO_EXTENSION getLabelHDRExtension(std::string nameFile)
getLabelHDRExtension returns the file label given its file name (for HDR images). ...
Definition: io.hpp:34
Definition: dynamic_range.hpp:29
The Image class stores an image as buffer of float.
Definition: image.hpp:60
PIC_INLINE unsigned char * ReadTGA(std::string nameFile, unsigned char *data, int &width, int &height, int &channels)
ReadTGA reads an image in the .tga format.
Definition: tga.hpp:62
static void div(T *data, int size, T value)
div
Definition: array.hpp:353
PIC_INLINE float * ReadPFM(std::string nameFile, float *data, int &width, int &height, int &channel)
ReadPFM loads a portable float map from a file.
Definition: pfm.hpp:59
Image * clone() const
Clone creates a deep copy of the calling instance.
void removeSpecials()
removeSpecials removes NaN and +/-Inf values and sets them to 0.0f.
PIC_INLINE bool WriteBMP(std::string nameFile, const unsigned char *data, int width, int height, int channels)
WriteBMP writes an image as a .bmp file.
Definition: bmp.hpp:188
float * getColorSamples(float *samples, int &nSamples, float percentage)
getColorSamples
Image * allocateSimilarOne()
allocateSimilarOne creates an Image with similar size of the calling instance.
int ystride
Definition: image.hpp:82
static T * subS(T *bufferOut, T *bufferIn, int n, int channels)
subS
Definition: buffer.hpp:280
Definition: dynamic_range.hpp:29
#define CLAMPi(x, a, b)
Definition: math.hpp:81
float * getPercentileVal(float percentile, BBox *box, float *ret)
getPercentileVal computes the n-th value given a percentile.
static void copySubBuffer(T *bufIn, int bi_width, int bi_height, int bi_channels, int startX, int startY, T *bufOut, int bo_width, int bo_height, int bo_channels)
copySubBuffer
Definition: buffer.hpp:746
Definition: dynamic_range.hpp:29
void operator=(const Image &a)
operator =
Definition: bilateral_separation.hpp:25
float getDiagonalSize()
getDiagonalSize
Definition: image.hpp:257
int tstride
Definition: image.hpp:82
PIC_INLINE float * ReadVOL(std::string nameFile, float *data, int &width, int &height, int &depth, int &channels)
ReadVOL.
Definition: vol.hpp:40
bool isValid()
isValid checks if the current image is valid, which means if they have an allocated buffer or not...
#define CLAMP(x, a)
Definition: math.hpp:77
LABEL_IO_EXTENSION
Definition: io.hpp:27
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
#define MAX(a, b)
Definition: math.hpp:73
void convertFromMask(bool *mask, int width, int height)
convertFromMask converts a boolean mask into an Image. true is mapped to 1.0f, and false is mapped to...
bool Read(std::string nameFile, LDR_type typeLoad)
Read opens an Image from a file on the disk.
void flipHV()
flipHV flips horizontally and vertically the current image.
Definition: image.hpp:220
static T * add(T *data, int size, T *ret)
add
Definition: array.hpp:334
static void flipH(T *buffer, int width, int height, int channels, int frames)
flipH flips a buffer horizontally
Definition: buffer.hpp:382
float * getMomentsVal(int x0, int y0, int radius, float *ret)
getMomentsVal computes the moments at pixel (x0, y0).
void copySubImage(Image *imgIn, int startX, int startY)
copySubImage copies imgIn in the current image. The current image is written from (startX...
PIC_INLINE bool WriteSTB(std::string nameFile, unsigned char *data, int width, int height, int channels=3)
WriteSTB.
Definition: stb.hpp:80
int sizeFrame() const
size computes the number of values.
Definition: image.hpp:490
PIC_INLINE bool WriteTGA(std::string nameFile, const unsigned char *data, int width, int height, int channels)
WriteTGA writes an image in the .tga format.
Definition: tga.hpp:139
PIC_INLINE LABEL_IO_EXTENSION getLabelLDRExtension(std::string nameFile)
getLabelHDRExtension returns the file label given its file name (for LDR images). ...
Definition: io.hpp:80
PIC_INLINE float * convertLDR2HDR(unsigned char *dataIn, float *dataOut, int size, LDR_type type, float gamma=2.2f)
convertLDR2HDR converts a buffer of unsigned char into float.
Definition: dynamic_range.hpp:78
void changeOwnership(bool notOwned)
changeOwnership
Definition: image.hpp:746
unsigned char * dataRGBE
dataRGBE is a buffer for rendering RGBE encoded images.
Definition: image.hpp:101
void setRand(unsigned int seed)
setRand
float * getMaxVal(BBox *box, float *ret)
getMaxVal computes the maximum value for the current Image.
PIC_INLINE float * ReadTMP(std::string nameFile, float *data, int &width, int &height, int &channels, int &frames, bool bHeader=true)
ReadTMP reads a dump temp file.
Definition: tmp.hpp:47
unsigned char * getdataUC()
getdataUC
Definition: image.hpp:464
static T * addS(T *bufferOut, T *bufferIn, int n, int channels)
Definition: buffer.hpp:125
PIC_INLINE float * ReadHDR(std::string nameFile, float *data, int &width, int &height)
ReadHDR reads a .hdr/.pic file.
Definition: hdr.hpp:38
int width
Definition: image.hpp:80
void rotate90CCW()
rotate90CCW rotates 90 degrees counter-clockwise the current image.
Definition: image.hpp:238
int height
Definition: image.hpp:80
void calculateStrides()
calculateStrides computes the strides values for pixels, lines and frames.
Definition: image.hpp:563
bool Write(std::string nameFile, LDR_type typeWrite, int writerCounter)
Write saves an Image into a file on the disk.
float * getVarianceVal(float *meanVal, BBox *box, float *ret)
getVarianceVal computes the variance for the current Image.
static T * BGRtoRGB(T *buffer, int width, int height, int channels, int frames)
BGRtoRGB swizzles from BGR to RGB a buffer.
Definition: buffer.hpp:659
PIC_INLINE unsigned char * convertHDR2LDR(const float *dataIn, unsigned char *dataOut, int size, LDR_type type, float gamma=2.2f)
convertHDR2LDR converts a buffer of float into unsigned char.
Definition: dynamic_range.hpp:132
void operator/=(const float &a)
operator /=
int readerCounter
Definition: image.hpp:71
static T * assign(T *buffer, int n, T value)
assign assigns value to buffer
Definition: buffer.hpp:45
const float C_INV_PI
Definition: math.hpp:62
void flipH()
FlipH flips horizontally the current image.
Definition: image.hpp:204
void operator+=(const float &a)
operator +=
PIC_INLINE unsigned char * ReadPPM(std::string nameFile, unsigned char *data, int &width, int &height, int &channels)
ReadPPM reads an .ppm file.
Definition: ppm.hpp:37
float frames1f
Definition: image.hpp:84
BBox getFullBox()
getFullBox computes a full BBox for this image.
PIC_INLINE float estimateAverageLuminance(float shutter_speed, float aperture_value=1.0f, float iso_value=1.0f, float K_value=12.5f)
estimateAverageLuminance estimates the average luminance of the shot.
Definition: dynamic_range.hpp:39
float width1f
Definition: image.hpp:84
bool checkCoordinates(int x, int y, int z=0)
checkCoordinates checks (x, y, z) coordinates) if they are valid or not.
Definition: image.hpp:512