CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxImageUtils.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxImageUtils.h
3// Description : Utilities to manage image as input
4// Author : Anders Modén
5// Product : CorTeX 2.0.1
6//
7// Copyright © 2015- Anders Modén, Sweden
8//
9// NOTE: CorTeX is a software development kit (SDK)
10// for neural networks and genetic programming.
11// Licensed by Anders Modén.
12//
13//
14// Revision History...
15//
16// Who Date Description
17//
18// AMO 170509 Created file (1.0.15)
19// AMO 261021 Share interpolation with standalone C++ without changing the interface (2.0.2)
20// AMO 261012 Added optional nearest/linear component sampling (2.0.2)
21//
22//******************************************************************************
23#ifndef __CTX_IMAGE_UTILS_H__
24#define __CTX_IMAGE_UTILS_H__
25
26#include "ctxBase.h"
27
29
30// -------------------- ctxImageAccessInterface --------------------------
31
33{
34public:
35
36 virtual gzUInt32 getNumberOfImages() = 0;
37
38 virtual gzUInt32 getImageWidth() = 0;
39 virtual gzUInt32 getImageHeight() = 0;
40 virtual gzUInt32 getImageDepth() = 0;
41
42 virtual gzFloat getComponentValue(gzUInt32 id,gzInt32 x, gzInt32 y, gzInt32 depth) = 0;
43
50 gzFloat getInterpolatedComponentValue(gzUInt32 id, gzDouble x, gzDouble y,
51 gzInt32 depth, ctxImageInterpolationType interpolation);
52};
53
55
56// --------------------- ctxImageNotifyInterface ----------------------
57
59{
60public:
61
62 virtual gzVoid onLoadImage(const gzString &name, const gzString &path, gzUInt32 index) = 0;
63};
64
66
67// -------------------- ctxCategoryManager .............................
68
70{
71public:
72
74
76
77 CTX_EXPORT gzUInt32 getCategory(const gzString &categoryName); // id 1..n
78
80
81private:
82
83 gzDynamicArray<gzUInt32> m_categoryIdCount;
84
85 gzDict<gzString, gzVoid> m_categories;
86
87};
88
89// ------------------------------ ctxImageCollectionInfo -------------------------------
90
92{
93 gzString name;
94 gzString path;
95 gzImagePtr image;
96
97 gzFloat mean[4];
98 gzFloat stddev[4];
99};
100
101// ------------------------- ctxImageCollection ----------------------------------------
102
122
124
125const gzString ALL_EXTENSIONS = "*";
126
128{
129public:
130
131 CTX_EXPORT ctxImageCollection(gzUInt32 width=0, gzUInt32 height = 0,gzUInt32 depth=0);
132
133 CTX_EXPORT gzBool loadImages(const gzString &directoryPath, const gzString &extension_list= ALL_EXTENSIONS,gzBool loadImmediately = FALSE,gzUInt32 maxImages=0xFFFFFFFFUL);
134
136
137 // ctxImageAccessInterface --
138
139 CTX_EXPORT virtual gzUInt32 getNumberOfImages() override;
140
141 CTX_EXPORT virtual gzString getImageName(gzUInt32 index);
142 CTX_EXPORT virtual gzString getImagePath(gzUInt32 index);
143
144 CTX_EXPORT virtual gzUInt32 getImageWidth() override;
145 CTX_EXPORT virtual gzUInt32 getImageHeight() override;
146 CTX_EXPORT virtual gzUInt32 getImageDepth() override;
147
148 CTX_EXPORT virtual gzFloat getMean(gzUInt32 index,gzUInt32 component);
149 CTX_EXPORT virtual gzFloat getStdDev(gzUInt32 index,gzUInt32 component);
150
151 CTX_EXPORT virtual gzFloat getComponentValue(gzUInt32 index, gzInt32 x, gzInt32 y, gzInt32 depth) override;
152
153 // -----------------------------------------------
154
155 CTX_EXPORT virtual gzBool isValidImage(gzImage *image, const gzString &name) { return TRUE; }
156
157 GZ_PROPERTY_EXPORT(ctxImageNormalizationType, NormalizationType, CTX_EXPORT);
158
159 GZ_PROPERTY_EXPORT(gzBool, KeepLoaded, CTX_EXPORT);
160
161 GZ_PROPERTY_EXPORT(gzInt32, StartX, CTX_EXPORT); // Offset into image X
162 GZ_PROPERTY_EXPORT(gzUInt32, Width, CTX_EXPORT); // Width of image. Can be set to less value to simulate border
163
164 GZ_PROPERTY_EXPORT(gzInt32, StartY, CTX_EXPORT); // Offset into image Y
165 GZ_PROPERTY_EXPORT(gzUInt32, Height, CTX_EXPORT); // Height of image. Can be set to less
166
167 GZ_PROPERTY_EXPORT(gzInt32, StartZ, CTX_EXPORT); // Offset into image Z
168 GZ_PROPERTY_EXPORT(gzUInt32, Depth, CTX_EXPORT); // Depth. Can be less
169
170 GZ_PROPERTY_EXPORT(gzBool, AllowAnySize, CTX_EXPORT); // TRUE to allow images of any sizes
171
172 GZ_PROPERTY_EXPORT(ctxImageNotifyInterfacePtr, NotifyInterface, CTX_EXPORT);
173
174private:
175
176 gzVoid normalizeImage(gzImage *image, gzUInt32 index);
177
178
179
180 gzDynamicArray<ctxImageCollectionInfo> m_imageInfo;
181
182 gzUInt32 m_currentIndex;
183
184 gzImagePtr m_currentImage;
185
186};
187
188
189
190#endif //__CTX_IMAGE_UTILS_H__
gzBool loadCategories()
gzUInt32 getCategories()
gzUInt32 getCategory(const gzString &categoryName)
gzBool saveCategories()
virtual gzFloat getComponentValue(gzUInt32 id, gzInt32 x, gzInt32 y, gzInt32 depth)=0
virtual gzUInt32 getImageHeight()=0
virtual gzUInt32 getNumberOfImages()=0
gzFloat getInterpolatedComponentValue(gzUInt32 id, gzDouble x, gzDouble y, gzInt32 depth, ctxImageInterpolationType interpolation)
Sample a component with explicit nearest/linear interpolation.
virtual gzUInt32 getImageDepth()=0
virtual gzUInt32 getImageWidth()=0
virtual gzFloat getMean(gzUInt32 index, gzUInt32 component)
virtual gzString getImagePath(gzUInt32 index)
virtual gzUInt32 getImageWidth() override
virtual gzFloat getStdDev(gzUInt32 index, gzUInt32 component)
virtual gzUInt32 getImageDepth() override
virtual gzFloat getComponentValue(gzUInt32 index, gzInt32 x, gzInt32 y, gzInt32 depth) override
virtual gzUInt32 getNumberOfImages() override
ctxImageCollection(gzUInt32 width=0, gzUInt32 height=0, gzUInt32 depth=0)
gzBool loadImages(const gzString &directoryPath, const gzString &extension_list=ALL_EXTENSIONS, gzBool loadImmediately=FALSE, gzUInt32 maxImages=0xFFFFFFFFUL)
virtual gzUInt32 getImageHeight() override
virtual gzBool isValidImage(gzImage *image, const gzString &name)
virtual gzString getImageName(gzUInt32 index)
virtual gzVoid onLoadImage(const gzString &name, const gzString &path, gzUInt32 index)=0
#define CTX_EXPORT
Definition ctxBase.h:68
GZ_USE_BIT_LOGIC(ctxInstrumentationFlags)
ctxImageInterpolationType
Explicit interpolation for caller-owned image accessors.
ctxImageAccessInterface * ctxImageAccessInterfacePtr
ctxImageNotifyInterface * ctxImageNotifyInterfacePtr
ctxImageNormalizationType
@ CTX_IMAGE_NORMALIZATION_STANDARD_MAX_CHANNEL
@ CTX_IMAGE_NORMALIZATION_RED_CHANNEL
@ CTX_IMAGE_NORMALIZATION_STANDARD
@ CTX_IMAGE_NORMALIZATION_BLUE_CHANNEL
@ CTX_IMAGE_NORMALIZATION_GREEN_CHANNEL
@ CTX_IMAGE_NORMALIZATION_DEFAULT
@ CTX_IMAGE_NORMALIZATION_MAX_VECTOR
@ CTX_IMAGE_NORMALIZATION_MEAN_ONLY
@ CTX_IMAGE_NORMALIZATION_STANDARD_VECTOR
@ CTX_IMAGE_NORMALIZATION_ALPHA_CHANNEL
@ CTX_IMAGE_NORMALIZATION_MASK
@ CTX_IMAGE_NORMALIZATION_OFF
@ CTX_IMAGE_NORMALIZATION_MEAN_ONLY_MAX_CHANNEL
const gzString ALL_EXTENSIONS