ICF 3.1.1.10
Technical documentation of ICF Libraries
TUnaryTransformProcessorComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iipr_TUnaryTransformProcessorComp_included
7#define iipr_TUnaryTransformProcessorComp_included
8
9
10// STL includes
11#include <functional>
12
13// ICF includes
15
16#ifdef max
17 #undef max
18#endif
19
20
21namespace iipr
22{
23
24
25template <typename ArgumentType>
27{
28public:
30 {
31 m_maxValue = std::numeric_limits<ArgumentType>::max();
32 }
33
34 inline ArgumentType operator()(const ArgumentType& value) const
35 {
36 return (m_maxValue - value);
37 }
38
39private:
40 ArgumentType m_maxValue;
41};
42
43
47template <typename PixelType, class Predicate>
49{
50public:
52
53 I_BEGIN_COMPONENT(TUnaryTransformProcessorComp);
54 I_END_COMPONENT;
55
56protected:
57 // reimplemented (iipr::CImageProcessorCompBase)
58 virtual bool ProcessImage(
59 const iprm::IParamsSet* paramsPtr,
60 const iimg::IBitmap& inputImage,
61 iimg::IBitmap& outputImage) const override;
62
63private:
64 Predicate m_predicate;
65};
66
67
68// reimplemented (iipr::CImageProcessorCompBase)
69
70template <typename PixelType, class Predicate>
72 const iprm::IParamsSet* /*paramsPtr*/,
73 const iimg::IBitmap& inputImage,
74 iimg::IBitmap& outputImage) const
75{
76 if (!outputImage.CreateBitmap(inputImage.GetPixelFormat(), inputImage.GetImageSize())){
77 SendErrorMessage(0, "Output bitmap could not be created");
78
79 return false; // cannot create output image
80 }
81
82 int imageWidth = inputImage.GetImageSize().GetX();
83 int imageHeight = inputImage.GetImageSize().GetY();
84 int componentsCount = inputImage.GetComponentsCount();
85
86 for (int y = 0; y < imageHeight; y++){
87 PixelType* inputImageLinePtr = (PixelType*)inputImage.GetLinePtr(y);
88 PixelType* outputImageLinePtr = (PixelType*)outputImage.GetLinePtr(y);
89
90 for (int x = 0; x < imageWidth; x++){
91 for (int colorComponentIndex = 0; colorComponentIndex < componentsCount; colorComponentIndex++){
92 int pixelOffset = x * componentsCount + colorComponentIndex;
93
94 outputImageLinePtr[pixelOffset] = m_predicate(inputImageLinePtr[pixelOffset]);
95 }
96 }
97 }
98
99 return true;
100}
101
102
104
105
106} // namespace iipr
107
108
109#endif // !iipr_TUnaryTransformProcessorComp_included
110
111
Definition of single plane bitmap.
Definition IBitmap.h:24
virtual PixelFormat GetPixelFormat() const =0
Get the bitmap's pixel format.
virtual const void * GetLinePtr(int positionY) const =0
Get pointer to buffer for single line.
virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, int pixelBitsCount=0, int componentsCount=0)=0
Create bitmap with specified size and format.
virtual int GetComponentsCount() const =0
Get number of color components.
virtual istd::CIndex2d GetImageSize() const =0
Get size of this raster image.
Basic implementation for a simple bitmap processor.
ArgumentType operator()(const ArgumentType &value) const
Implementation of general morphological operator.
virtual bool ProcessImage(const iprm::IParamsSet *paramsPtr, const iimg::IBitmap &inputImage, iimg::IBitmap &outputImage) const override
Set of general parameters.
Definition IParamsSet.h:29
int GetX() const
Definition CIndex2d.h:105
int GetY() const
Definition CIndex2d.h:117
Contains the image processing classes.
TUnaryTransformProcessorComp< quint8, InvertFunction< quint8 > > CInvertOperatorComp

© Witold Gantzke and Kirill Lepskiy