3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
ValuesField.h
1#pragma once
2enum FieldClamp {
3 fcWrap = 0,
4 fcClamp=1,
5 fcZero=2
6};
7
11class APICALL ValuesField {
12 int Lx, Ly, Depth;
13 cList<float> values;
14 FieldClamp clamp;
15public:
18
26 void create(int SizeX, int SiezY, int depth = 1, FieldClamp clampmode = fcWrap);
27
32 void setClampMode(FieldClamp cl);
33
38 int width();
39
44 int height();
45
50 int depth();
51
56 void createFromImage(const comms::cImage& im);
57
63 void createFromImageMono(const comms::cImage& im, Vector3D mask = Vector3D(2.0f/9.0f, 6.0f/9.0f, 1.0f/9.0f));
64
69 void toImage(comms::cImage& im);
70
75 void loadImage(const char* name);
76
81 void saveImage(const char* name);
82
86 void clear();
87
94 bool torange(int& x, int& y) const;
95
103 void set(float value, int x, int y, int channel = 0);
104
112 void add(float value, int x, int y, int channel = 0);
113
121 float get(int x, int y, int channel = 0) const ;
122
130 float& value(int x, int y, int channel = 0);
131
138 Vector3D& getV3(int x, int y);
139
146 Vector4D& getV4(int x, int y);
147
154 cVec2& getV2(int x, int y);
155
163 float get_linear(float x, float y, int channel = 0) const ;
164
172 cVec2 get_linearV2(float x, float y);
173
181 cVec3 get_linearV3(float x, float y);
182
190 cVec4 get_linearV4(float x, float y);
191
199 float get_bicubic(float x, float y, int channel = 0) const ;
200
208 cVec2 get_bicubicV2(float x, float y);
209
217 cVec3 get_bicubicV3(float x, float y);
218
226 cVec4 get_bicubicV4(float x, float y);
227
233
238 void sharp2X(ValuesField& dest);
239
245
251
257 void sharpResize(ValuesField& dest, float scale);
258
265 void relax(ValuesField& destination, float degree, float radius);
266 void relax(ValuesField& destination, float degree, float radius, int x0, int y0, int x1, int y1);
267
268
275 void sharpen(ValuesField& destination, float degree, float radius);
276
281 void monoTo(ValuesField& dest);
282
288
294
300 void normalmap(ValuesField& dest, int byChannel = 0);
301
308 void normalmap3(ValuesField& dest, float heightmod = 1.0, int channel = 0);
309
315
316 //experimental functions...
317 void perlinMap(ValuesField& dest);
318 void detectAnisotropy(ValuesField& dest);
319 float detectPerlin(int x, int y, int channel);
320
325 void operator -= (const ValuesField& field);
326
331 void operator += (const ValuesField& field);
332
337 void operator += (float value);
338
343 void operator -= (float value);
344
349 void operator *= (float value);
350
355 void operator /= (float value);
356
361 void generatePerlin(float Sharpness);
362
367 void operate(const std::function<void(int, int) >& f, bool multithread = true);
368
373 void max(ValuesField& other);
374
379 void swap(ValuesField& dest);
380
387
393 void LaplacianInterpolate(const UnlimitedBitset& fixed);
394
400 void NormalizeColors(bool monochromatic = false, int mipsize = 64);
401
407
413
419};
420
421inline int ValuesField::width() {
422 return Lx;
423}
424
426 return Ly;
427}
428
429inline int ValuesField::depth() {
430 return Depth;
431}
432
The class to operate over the 2D fields.
Definition ValuesField.h:11
void relax(ValuesField &destination, float degree, float radius)
relax the field
float get_bicubic(float x, float y, int channel=0) const
get the bicubic interpolated value
void sharpen(ValuesField &destination, float degree, float radius)
sharpen the field
void sharp2X(ValuesField &dest)
Experimental: Increase the image 2X and sharpen.
void toImage(comms::cImage &im)
convert the field to the image
void LaplacianInterpolate(const cList< Vector3D > &lines)
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and gets the ...
float get(int x, int y, int channel=0) const
get the value of the field by the integer coordinates
void swap(ValuesField &dest)
swap two fields (dimensions may be different)
cVec2 get_bicubicV2(float x, float y)
get the bicubic interpolated value as the 2d-vector
cVec4 get_linearV4(float x, float y)
get the linearly interpolated value as 4d-vector
void sharpResize(ValuesField &dest, float scale)
resize to bigger size keeping the edges sharpness
cVec4 get_bicubicV4(float x, float y)
get the bicubic interpolated value as the 4d-vector
int depth()
Get amount of channels.
Definition ValuesField.h:429
void clear()
clear rthe field
void LaplacianInterpolate(const UnlimitedBitset &fixed)
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and keeps the...
int height()
get height
Definition ValuesField.h:425
void sharpEdges2X1(ValuesField &dest)
Experimental, variation of the previous function: Increase the image 2X and sharpen (sharpening edges...
void create(int SizeX, int SiezY, int depth=1, FieldClamp clampmode=fcWrap)
Create the field.
void setClampMode(FieldClamp cl)
set the field clamp mode - how it acts beyond the boundaries
void NormalizeColors(bool monochromatic=false, int mipsize=64)
Normalize the texture to be (128, 128, 128) in average using the mip-mapping algorithm.
void normalmap(ValuesField &dest, int byChannel=0)
calculate the normalmap
int width()
get width
Definition ValuesField.h:421
void toPower2(ValuesField &dest)
resize to the closest power of 2 (may increase, may decrease the size, we choose what is arithmetical...
void recoverBump(ValuesField &dest)
recover the bump from the color/greyscale (heuristic)
float get_linear(float x, float y, int channel=0) const
get the linearly interpolated value
void set(float value, int x, int y, int channel=0)
set teh value to the field
cVec2 & getV2(int x, int y)
get the reference to the values as 2d - vector. It has sense only if there are at least 2 channels
void normalmap3(ValuesField &dest, float heightmod=1.0, int channel=0)
calculate the normalmap as the 3d-vectors set
void curvature(ValuesField &dest)
calculate the curvature of the 2d-field
float & value(int x, int y, int channel=0)
get the value reference of the field by the integer coordinates
cVec2 get_linearV2(float x, float y)
get the linearly interpolated value as 2d-vector
void saveImage(const char *name)
save the field directly to file
void curvatureDir(ValuesField &dest)
calculate the curvature principal directions
void sharpEdges2X(ValuesField &dest)
Experimental: Increase the image 2X and sharpen (sharpening edges so that edge width will be kept des...
bool torange(int &x, int &y) const
converts the (x,y) to range [0..Lx-1, 0..Ly-1]
void createFromImage(const comms::cImage &im)
create the field form the image
void gradientValue(ValuesField &dest)
calculate the gradient length
void add(float value, int x, int y, int channel=0)
add the value to the field
void operate(const std::function< void(int, int) > &f, bool multithread=true)
operate over the field with the lambda
cVec3 get_linearV3(float x, float y)
get the linearly interpolated value as 3d-vector
void monoTo(ValuesField &dest)
convert multiple channels to one as an average-arithmetic
void resizeTo(ValuesField &dest)
resize the field to other size using the bicubic interpolation
void generatePerlin(float Sharpness)
generate the perlin noise
cVec3 get_bicubicV3(float x, float y)
get the bicubic interpolated value as the 3d-vector
void Decrease2X(ValuesField &dest)
Decrease the field 2X times.
void max(ValuesField &other)
calculated the maximum of two fields into hte current
void createFromImageMono(const comms::cImage &im, Vector3D mask=Vector3D(2.0f/9.0f, 6.0f/9.0f, 1.0f/9.0f))
create the monochromatic field from the image (1 channel)
Vector3D & getV3(int x, int y)
get the reference to the values as 3d - vector. It has sense only if there are at least 3 channels
Vector4D & getV4(int x, int y)
get the reference to the values as 4d - vector. It has sense only if there are at least 4 channels
void loadImage(const char *name)
read the image directly from the file
The array template, refer it as coat::list <...> if you are using the Core API.
Definition cList.h:133
The 2D-vector, refer it as coat::vec2 in the Core API.
Definition cVec2.h:9
The 3D-vector, refer it as coat::vec3 in the Core API.
Definition cVec3.h:10
The 4D-vector, refer it as coat::vec4 in the Core API.
Definition cVec4.h:9