25 #include <Base/Image/Image.hh>
26 #include <Base/Image/ImageConvert.hh>
29 #include <Base/Common/BIASpragma.hh>
40 template <
class StorageType>
45 BIASGDOUT(D_IMAGE_TRACE,
46 "called Image::operator=(const ImageBase& Source)"
48 <<
" this->GetStorageType = "<<GetStorageType()
49 <<
" this->TemplateType = "<<PRINTTYPE(StorageType));
56 BEXCEPTION(
"Images have different storage type. Use ConvertST()");
81 #define GRAYTEST(OPERATOR) \
82 if (GetChannelCount() != 1) { \
83 BIASERR("Operation " << OPERATOR << " is only defined on gray images. Leaving images unchanged! Aborting!"); \
88 #define GRAYTEST(OPERATOR)
98 template <
class StorageType>
107 BIASERR(
"Computation not possible: 'Region Of Interest' do not "
108 <<
"match in size! Aborting!");
124 template <
class StorageType>
129 unsigned int minx, miny, maxx, maxy;
130 GetROICorners(minx, miny, maxx, maxy);
131 register int width=(int)GetWidth(), step=width-maxx+minx;
132 StorageType *p=GetImageData()+width*miny+minx;
133 StorageType *le=GetImageData()+width*miny+maxx;
134 StorageType *e=GetImageData()+width*(maxy-1)+maxx;
153 template <
class StorageType>
158 unsigned int minx, miny, maxx, maxy;
159 GetROICorners(minx, miny, maxx, maxy);
160 register int width=(int)GetWidth(), step=width-maxx+minx;
161 register StorageType *p=GetImageData()+width*miny+minx;
162 register StorageType *le=GetImageData()+width*miny+maxx;
163 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
177 template <
class StorageType>
182 unsigned int minx, miny, maxx, maxy;
183 GetROICorners(minx, miny, maxx, maxy);
184 register int width=(int)GetWidth(), step=width-maxx+minx;
185 width *= GetChannelCount();
186 step *= GetChannelCount();
187 register StorageType *p = GetImageData()+width*miny +minx;
188 register StorageType *le = GetImageData()+width*miny +maxx;
189 register StorageType *e = GetImageData()+width*(maxy-1) +maxx;
203 template <
class StorageType>
206 if (Value == (StorageType) 0) {
207 BIASERR(
"Division by zero attempted on image. Aborting!");
213 unsigned int minx, miny, maxx, maxy;
214 GetROICorners(minx, miny, maxx, maxy);
215 register int width=(int)GetWidth(), step=width-maxx+minx;
216 register StorageType *p=GetImageData()+width*miny+minx;
217 register StorageType *le=GetImageData()+width*miny+maxx;
218 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
240 template <
class StorageType>
246 unsigned int minx, miny, maxx, maxy;
247 GetROICorners(minx, miny, maxx, maxy);
248 register int width=(int)GetWidth(), step=width-maxx+minx;
249 register StorageType *p=GetImageData()+width*miny+minx;
250 register StorageType *le=GetImageData()+width*miny+maxx;
251 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
252 register const StorageType *argimagedata=argimage.
GetImageData()+width*miny+minx;
255 *p++ += *argimagedata++;
271 unsigned int minx, miny, maxx, maxy;
272 GetROICorners(minx, miny, maxx, maxy);
273 register int width=(int)GetWidth(), step=width-maxx+minx;
274 register StorageType *p=GetImageData()+width*miny+minx;
275 register StorageType *le=GetImageData()+width*miny+maxx;
276 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
277 register const StorageType *argimagedata=argimage.
GetImageData()+width*miny+minx;
280 *p++ -= *argimagedata++;
296 unsigned int minx, miny, maxx, maxy;
297 GetROICorners(minx, miny, maxx, maxy);
298 register int width=(int)GetWidth(), step=width-maxx+minx;
299 register StorageType *p=GetImageData()+width*miny+minx;
300 register StorageType *le=GetImageData()+width*miny+maxx;
301 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
302 register const StorageType *argimagedata=argimage.
GetImageData()+width*miny+minx;
305 *p++ *= *argimagedata++;
320 unsigned int minx, miny, maxx, maxy;
321 GetROICorners(minx, miny, maxx, maxy);
322 register int width=(int)GetWidth(), step=width-maxx+minx;
323 register StorageType *p=GetImageData()+width*miny+minx;
324 register StorageType *le=GetImageData()+width*miny+maxx;
325 register StorageType *e=GetImageData()+width*(maxy-1)+maxx;
326 register const StorageType *argimagedata=argimage.
GetImageData()+width*miny+minx;
329 if(*argimagedata != (StorageType) 0)
351 template <
class StorageType>
354 if (Value == (StorageType) 0) {
355 BIASERR(
"Division by zero attempted on image. Aborting!");
363 result.
Init(GetWidth(), GetHeight(), GetChannelCount());
375 template <
class StorageType>
393 template <
class StorageType>
411 template <
class StorageType>
418 result.
Init(GetWidth(), GetHeight(), GetChannelCount());
453 BIASERR(
"unmatching ROIs");
476 BIASERR(
"unmatching ROIs");
500 BIASERR(
"unmatching ROIs");
523 BIASERR(
"unmatching ROIs");
535 BIASERR(
"operator| not implemented for StorageType");
550 BIASERR(
"Image::operator| not implemented for images with ROIs");
552 BIASERR(
"unmatching ROIs");
577 BIASERR(
"Image::operator| not implemented for images with ROIs");
579 BIASERR(
"unmatching ROIs");
597 template <
class StorageType>
void
603 BIASERR(
"images are not of same size or channelcount");
605 if (!IsEmpty()) Release();
612 unsigned minx, miny, maxx, maxy;
614 StorageType **ida=GetImageDataArray();
618 for (
unsigned y=miny; y<maxy; y++){
619 for (
unsigned x=minx; x<maxx; x+= cc){
620 for (
unsigned int c=0;c<cc; c++) {
621 ida[y][x+c]=(ida1[y][x+c]>ida2[y][x+c])?
622 (ida1[y][x+c]-ida2[y][x+c]):(ida2[y][x+c]-ida1[y][x+c]);
627 BIASERR(
"unmatching ROIs");
const unsigned int GetROIUpperLeftX() const
deprecated, use GetROI()->GetCorners()
ImageBase & operator=(const ImageBase &Source)
assignment operator, allocates memory structure via Init only if necessary
Image< StorageType > & operator-=(const StorageType &argimage)
Operator -= for scalar value.
Image< StorageType > & operator+=(const StorageType &argimage)
Operator += for scalar value.
unsigned int GetWidth() const
const unsigned int GetROIUpperLeftY() const
deprecated, use GetROI()->GetCorners()
Image< StorageType > & operator|(const Image< StorageType > &argimage)
logical Operator || operating pixel values with pixel values of another image, returning a new image ...
const unsigned int GetROILowerRightY() const
deprecated, use GetROI()->GetCorners()
int GetDebugLevel() const
void GetROICorners(unsigned int &UpperLeftX, unsigned int &UpperLeftY, unsigned int &LowerRightX, unsigned int &LowerRightY) const
access region of interest rectangle JW
Image< StorageType > operator/(const StorageType &argimage) const
Operator / for scalar value, returning a new image.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
Image< StorageType > operator-(const StorageType &argimage) const
Operator - for scalar value, returning a new image.
The image template class for specific storage types.
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
Image< StorageType > operator*(const StorageType &argimage) const
Operator * for scalar value, returning a new image.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Image< StorageType > & operator=(const ImageBase &Source)
copies ImageBase to an desired Image<>, be careful with this, because u can do something like: Image<...
bool HaveImagesMatchingROI(const Image< StorageType > &i1, const Image< StorageType > &i2)
Test the the dimensions of the ROI of two images.
Image< StorageType > operator+(const StorageType &argimage) const
Operator + for scalar value, returning a new image.
const unsigned int GetROILowerRightX() const
deprecated, use GetROI()->GetCorners()
enum EStorageType GetStorageType() const
Image< StorageType > & operator/=(const StorageType &argimage)
Operator /= for scalar value.
This is the base class for images in BIAS.
void PrintROI(std::ostream &os=std::cout) const
deprecated, use 'os << *GetROI()'
Image< StorageType > & operator*=(const StorageType &argimage)
Operator *= for scalar value.
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase