34 #include "Core/include/private/DImage.hpp"
35 #include "Base/include/private/DImageArith.hpp"
36 #include "Core/include/DTypes.h"
37 #include "Base/include/private/DImageTransform.hpp"
38 #include "Base/include/private/DMeasures.hpp"
44 inline void Image<RGB>::init()
52 dataTypeSize =
sizeof(pixelType);
59 updatesEnabled =
true;
65 inline RES_T Image< RGB >::restruct(
void)
68 delete[] this->slices;
72 this->lines =
new lineType[lineCount];
73 this->slices =
new sliceType[sliceCount];
75 sliceType cur_line = this->lines;
76 volType cur_slice = this->slices;
78 size_t pixelsPerSlice = this->width * this->height;
80 for (
size_t k=0; k<depth; k++, cur_slice++)
82 *cur_slice = cur_line;
84 for (
size_t j=0; j<height; j++, cur_line++)
86 for (UINT n=0;n<3;n++)
87 (*cur_line).arrays[n] = pixels.arrays[n] + k*pixelsPerSlice + j*width;
114 return RES_ERR_BAD_ALLOCATION;
118 this->pixels.createArrays(this->pixelCount);
121 ASSERT((this->pixels.isAllocated()),
"Can't allocate image", RES_ERR_BAD_ALLOCATION);
123 this->allocated =
true;
124 this->allocatedSize = 3*this->pixelCount*
sizeof(UINT8);
134 if (!this->allocated)
138 delete[] this->slices;
140 delete[] this->lines;
141 if (this->pixels.isAllocated())
142 this->pixels.deleteArrays();
147 for (UINT n=0;n<3;n++)
148 this->pixels.arrays[n] = NULL;
150 this->allocated =
false;
151 this->allocatedSize = 0;
157 inline double vol(
const Image<RGB> &imIn)
159 if (!imIn.isAllocated())
160 return RES_ERR_BAD_ALLOCATION;
162 int npix = imIn.getPixelCount();
163 ImDtTypes<UINT8>::lineType pixels;
166 for (UINT n=0;n<3;n++)
168 pixels = imIn.getPixels().arrays[n];
169 for (
int i=0;i<npix;i++)
170 vol +=
double(pixels[i]);
177 inline Image<RGB>::operator bool()
179 return vol(*
this)==255 * pixelCount * 3;
207 inline char *Image<RGB>::toCharArray()
209 cout <<
"Not implemented for RGB images" << endl;
virtual void * getVoidPointer(void)
Get pixels as a void pointer.
Definition: DImage.hpp:291
virtual RES_T allocate()
Allocate image.
virtual RES_T deallocate()
Deallocate image.
double vol(const Image< T > &imIn)
vol() - Volume of an image
Definition: DMeasures.hpp:129