3DCoat Core API
The 3DCoat API documentation.
|
The class to operate over the 2D fields. More...
#include <ValuesField.h>
Public Member Functions | |
ValuesField (const ValuesField &vf, int x=0, int y=0, int w=0, int h=0) | |
construct the field from the other cropped field | |
void | create (int SizeX, int SiezY, int depth=1, FieldClamp clampmode=fcWrap) |
Create the field. | |
void | createMips () |
create the mipmaps, decreasing twice with each level until it is possible | |
void | setClampMode (FieldClamp cl) |
set the field clamp mode - how it acts beyond the boundaries | |
int | width () const |
get width | |
int | height () const |
get height | |
int | depth () const |
Get amount of channels. | |
void | createFromImage (const comms::cImage &im) |
create the field form the image | |
void | createFromImageMono (const comms::cImage &im, Vector3D mask=Vector3D::Zero) |
create the monochromatic field from the image (1 channel) | |
void | toImage (comms::cImage &im) |
convert the field to the image | |
void | loadImage (const char *name) |
read the image directly from the file | |
void | saveImage (const char *name) |
save the field directly to file | |
void | clear () |
clear rthe field | |
bool | torange (int &x, int &y) const |
converts the (x,y) to range [0..Lx-1, 0..Ly-1] | |
void | set (float value, int x, int y, int channel=0) |
set teh value to the field | |
void | add (float value, int x, int y, int channel=0) |
add the value to the field | |
float | get (int x, int y, int channel=0) const |
get the value of the field by the integer coordinates | |
float & | value (int x, int y, int channel=0) |
get the value reference of the field by the integer coordinates | |
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 | |
Vector3D | getV3 (int x, int y) const |
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 | |
Vector4D | getV4 (int x, int y) const |
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 | |
cVec2 | getV2 (int x, int y) const |
float | get_linear (float x, float y, int channel=0) const |
get the linearly interpolated value | |
float | get_linear_mip (float x, float y, int channel, float mip_level) const |
get the linearly interpolated value using the mipmaps | |
cVec2 | get_linearV2 (float x, float y) const |
get the linearly interpolated value as 2d-vector | |
cVec2 | get_linearV2_mip (float x, float y, float mip_level) const |
get the linearly interpolated value as 2d-vector using the mipmaps | |
cVec3 | get_linearV3 (float x, float y) const |
get the linearly interpolated value as 3d-vector | |
cVec3 | get_linearV3_mip (float x, float y, float mip_level) const |
get the linearly interpolated value as 3d-vector using the mipmaps | |
cVec4 | get_linearV4 (float x, float y) const |
get the linearly interpolated value as 4d-vector | |
cVec4 | get_linearV4_mip (float x, float y, float mip_level) const |
get the linearly interpolated value as 4d-vector using the mipmaps | |
float | get_bicubic (float x, float y, int channel=0) const |
get the bicubic interpolated value | |
float | get_bicubic_mip (float x, float y, int channel, float mip_level) const |
get the bicubic interpolated value using the mipmaps | |
cVec2 | get_bicubicV2 (float x, float y) const |
get the bicubic interpolated value as the 2d-vector | |
cVec2 | get_bicubicV2_mip (float x, float y, float mip_level) const |
get the bicubic interpolated value as the 2d-vector using the mipmaps | |
cVec3 | get_bicubicV3 (float x, float y) const |
get the bicubic interpolated value as the 3d-vector | |
cVec3 | get_bicubicV3_mip (float x, float y, float mip_level) const |
get the bicubic interpolated value as the 3d-vector using the mipmaps | |
cVec4 | get_bicubicV4 (float x, float y) const |
get the bicubic interpolated value as the 4d-vector | |
cVec4 | get_bicubicV4_mip (float x, float y, float mip_level) const |
get the bicubic interpolated value as the 4d-vector using the mipmaps | |
void | resizeTo (ValuesField &dest) |
resize the field to other size using the bicubic interpolation | |
void | sharp2X (ValuesField &dest) |
Experimental: Increase the image 2X and sharpen. | |
void | sharpEdges2X (ValuesField &dest) |
Experimental: Increase the image 2X and sharpen (sharpening edges so that edge width will be kept despite on the image size increasing) | |
void | sharpEdges2X1 (ValuesField &dest) |
Experimental, variation of the previous function: Increase the image 2X and sharpen (sharpening edges so that edge width will be kept despite on the image size increasing) | |
void | sharpResize (ValuesField &dest, float scale) |
resize to bigger size keeping the edges sharpness | |
void | relax (ValuesField &destination, float degree, float radius) |
relax the field | |
void | relax (ValuesField &destination, float degree, float radius, int x0, int y0, int x1, int y1) |
void | sharpen (ValuesField &destination, float degree, float radius) |
sharpen the field | |
void | monoTo (ValuesField &dest) |
convert multiple channels to one as an average-arithmetic | |
void | curvature (ValuesField &dest) |
calculate the curvature of the 2d-field | |
void | curvatureDir (ValuesField &dest) |
calculate the curvature principal directions | |
void | normalmap (ValuesField &dest, int byChannel=0) |
calculate the normalmap | |
void | normalmap3 (ValuesField &dest, float heightmod=1.0, int channel=0) |
calculate the normalmap as the 3d-vectors set | |
void | gradientValue (ValuesField &dest) |
calculate the gradient length | |
void | perlinMap (ValuesField &dest) |
void | detectAnisotropy (ValuesField &dest) |
float | detectPerlin (int x, int y, int channel) |
void | operator-= (const ValuesField &field) |
subtract field from the current | |
void | operator+= (const ValuesField &field) |
add field to the current | |
void | operator+= (float value) |
add the constant value to the field | |
void | operator-= (float value) |
subtract the value from the field | |
void | operator*= (float value) |
multiply on the constant | |
void | operator/= (float value) |
divide on the constant | |
void | operate (const std::function< void(int, int) > &f, bool multithread=true) |
operate over the field with the lambda | |
void | max (ValuesField &other) |
calculated the maximum of two fields into hte current | |
void | swap (ValuesField &dest) |
swap two fields (dimensions may be different) | |
void | LaplacianInterpolate (const cList< Vector3D > &lines) |
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and gets the given values at the each line provided, so that field_value(point.x,point.y) = point.z. This is heavy function, be careful with the timing. But it produces absolutely clean and smooth field. | |
void | LaplacianInterpolate (const UnlimitedBitset &fixed) |
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and keeps the grid value at each locked point. This is heavy function, be careful with the timing. But it produces absolutely clean and smooth field. | |
void | NormalizeColors (bool monochromatic=false, int mipsize=64) |
Normalize the texture to be (128, 128, 128) in average using the mip-mapping algorithm. | |
comms::cVec3 | averageColor (int x=0, int y=0, int w=0, int h=0, float alpha_threshold=200) const |
get the average color of the texture piece | |
void | Decrease2X (ValuesField &dest) |
Decrease the field 2X times. | |
void | toPower2 (ValuesField &dest) |
resize to the closest power of 2 (may increase, may decrease the size, we choose what is arithmetically closer) | |
void | recoverBump (ValuesField &dest) |
recover the bump from the color/greyscale (heuristic) | |
comms::cBounds | blendImage (const ValuesField &other, const cMat3 &transform, const cVec4 &modulator=cVec4::One) |
blend the image with the other image | |
comms::cBounds | blendImageM4 (const ValuesField &other, const comms::cMat4 &transform, const cVec4 &modulator=cVec4::One) |
blend the image with the other image using the 4x4 matrix transformation | |
void | rect (int x0, int y0, int x1, int y1, const cVec4 &color) |
draw the filled rectangle | |
void | calc_featuremap (ValuesField &dest, int radius) |
void | local_normalisation (ValuesField &dest, int size) |
void | find_local_minmax (std::vector< comms::cVec2 > &minmax) |
void | getEllipse (int x, int y, cVec2 ¢er, cVec2 &longer_axis, float &relation) |
The class to operate over the 2D fields.
ValuesField::ValuesField | ( | const ValuesField & | vf, |
int | x = 0, | ||
int | y = 0, | ||
int | w = 0, | ||
int | h = 0 ) |
construct the field from the other cropped field
vf | the field to copy |
x | the x-coordinate of the left-top corner (of the vf) |
y | the y-coordinate of the left-top corner (of the vf) |
w | the width of the field, if zero the whole field will be copied (shifted on x) |
h | the height of the field, if zero the whole field will be copied (shifted on y) |
void ValuesField::add | ( | float | value, |
int | x, | ||
int | y, | ||
int | channel = 0 ) |
add the value to the field
value | the value to add |
x | x-coordinate |
y | y-coordinate |
channel | the channel |
comms::cVec3 ValuesField::averageColor | ( | int | x = 0, |
int | y = 0, | ||
int | w = 0, | ||
int | h = 0, | ||
float | alpha_threshold = 200 ) const |
get the average color of the texture piece
x | the x-coordinate of the piece |
y | the y-coordinate of the piece |
w | the width of the piece, iw w == 0, the whole texture width is taken |
h | the height of the piece, if h == 0, the whole texture height is taken |
alpha_threshold | the threshold for the alpha channel (if exists) |
comms::cBounds ValuesField::blendImage | ( | const ValuesField & | other, |
const cMat3 & | transform, | ||
const cVec4 & | modulator = cVec4::One ) |
blend the image with the other image
other | the other image to blend with this image, it should be of the 4-channels in depth (color + alpha) |
transform | the transformation matrix applied to the other image |
modulator | the color/alpha modulator |
comms::cBounds ValuesField::blendImageM4 | ( | const ValuesField & | other, |
const comms::cMat4 & | transform, | ||
const cVec4 & | modulator = cVec4::One ) |
blend the image with the other image using the 4x4 matrix transformation
other | the other image to blend with this image, it should be of the 4-channels in depth (color + alpha) |
transform | the transformation matrix applied to the other image |
modulator | the color/alpha modulator |
void ValuesField::create | ( | int | SizeX, |
int | SiezY, | ||
int | depth = 1, | ||
FieldClamp | clampmode = fcWrap ) |
Create the field.
SizeX | width |
SiezY | height |
depth | channels count |
clampmode | clamp mode |
void ValuesField::createFromImage | ( | const comms::cImage & | im | ) |
create the field form the image
im | the image to be converted to the float field |
void ValuesField::createFromImageMono | ( | const comms::cImage & | im, |
Vector3D | mask = Vector3D::Zero ) |
create the monochromatic field from the image (1 channel)
im | the image, if it is RGB, the channels will be merged to greyscale |
mask | the mask to blend rgb - channels, if zero - the default rgb mask will be used |
void ValuesField::curvature | ( | ValuesField & | dest | ) |
calculate the curvature of the 2d-field
dest | the destination field (1 channel) |
void ValuesField::curvatureDir | ( | ValuesField & | dest | ) |
calculate the curvature principal directions
dest | the destination field (3channels) |
void ValuesField::Decrease2X | ( | ValuesField & | dest | ) |
Decrease the field 2X times.
dest | the destination field |
|
inline |
Get amount of channels.
float ValuesField::get | ( | int | x, |
int | y, | ||
int | channel = 0 ) const |
get the value of the field by the integer coordinates
x | x-coordinate |
y | y-coordinate |
channel | the channel |
float ValuesField::get_bicubic | ( | float | x, |
float | y, | ||
int | channel = 0 ) const |
get the bicubic interpolated value
x | x-coordinate |
y | y-coordinate |
channel | the channel |
float ValuesField::get_bicubic_mip | ( | float | x, |
float | y, | ||
int | channel, | ||
float | mip_level ) const |
get the bicubic interpolated value using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
channel | the channel |
mip_level | the mip level |
cVec2 ValuesField::get_bicubicV2 | ( | float | x, |
float | y ) const |
get the bicubic interpolated value as the 2d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec2 ValuesField::get_bicubicV2_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the bicubic interpolated value as the 2d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
cVec3 ValuesField::get_bicubicV3 | ( | float | x, |
float | y ) const |
get the bicubic interpolated value as the 3d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec3 ValuesField::get_bicubicV3_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the bicubic interpolated value as the 3d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
cVec4 ValuesField::get_bicubicV4 | ( | float | x, |
float | y ) const |
get the bicubic interpolated value as the 4d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec4 ValuesField::get_bicubicV4_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the bicubic interpolated value as the 4d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
float ValuesField::get_linear | ( | float | x, |
float | y, | ||
int | channel = 0 ) const |
get the linearly interpolated value
x | x-coordinate |
y | y-coordinate |
channel | the channel |
float ValuesField::get_linear_mip | ( | float | x, |
float | y, | ||
int | channel, | ||
float | mip_level ) const |
get the linearly interpolated value using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
channel | the channel |
mip_level | the mip level |
cVec2 ValuesField::get_linearV2 | ( | float | x, |
float | y ) const |
get the linearly interpolated value as 2d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec2 ValuesField::get_linearV2_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the linearly interpolated value as 2d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
cVec3 ValuesField::get_linearV3 | ( | float | x, |
float | y ) const |
get the linearly interpolated value as 3d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec3 ValuesField::get_linearV3_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the linearly interpolated value as 3d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
cVec4 ValuesField::get_linearV4 | ( | float | x, |
float | y ) const |
get the linearly interpolated value as 4d-vector
x | x-coordinate |
y | y-coordinate |
channel | the channel |
cVec4 ValuesField::get_linearV4_mip | ( | float | x, |
float | y, | ||
float | mip_level ) const |
get the linearly interpolated value as 4d-vector using the mipmaps
x | the x-coordinate |
y | the y-coordinate |
mip_level | the mip level |
cVec2 & ValuesField::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
x | x-coordinate |
y | y-coordinate |
Vector3D & ValuesField::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
x | x-coordinate |
y | y-coordinate |
Vector4D & ValuesField::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
x | x-coordinate |
y | y-coordinate |
void ValuesField::gradientValue | ( | ValuesField & | dest | ) |
calculate the gradient length
dest | the 1d field |
|
inline |
get height
void ValuesField::LaplacianInterpolate | ( | const cList< Vector3D > & | lines | ) |
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and gets the given values at the each line provided, so that field_value(point.x,point.y) = point.z. This is heavy function, be careful with the timing. But it produces absolutely clean and smooth field.
lines | the pairs of points that define the field, x,y of each point may be not integer, the count of points should be even |
void ValuesField::LaplacianInterpolate | ( | const UnlimitedBitset & | fixed | ) |
Interpolates the whole field so that it is maximally smooth (laplacian value minimized) and keeps the grid value at each locked point. This is heavy function, be careful with the timing. But it produces absolutely clean and smooth field.
fixed | The fixel points falgs, fixed.get(x+y*width) == true means that point is fixed |
void ValuesField::loadImage | ( | const char * | name | ) |
read the image directly from the file
name | the filename |
void ValuesField::max | ( | ValuesField & | other | ) |
calculated the maximum of two fields into hte current
other | the other field |
void ValuesField::monoTo | ( | ValuesField & | dest | ) |
convert multiple channels to one as an average-arithmetic
dest |
void ValuesField::NormalizeColors | ( | bool | monochromatic = false, |
int | mipsize = 64 ) |
Normalize the texture to be (128, 128, 128) in average using the mip-mapping algorithm.
monochromatic | set true to change the brightness only |
mipsize | the mip-map size to be used to normalize the color |
void ValuesField::normalmap | ( | ValuesField & | dest, |
int | byChannel = 0 ) |
calculate the normalmap
dest | the destination field (2 channels, only dx and dy will be written) |
byChannel | the channel to be used as the depth source |
void ValuesField::normalmap3 | ( | ValuesField & | dest, |
float | heightmod = 1.0, | ||
int | channel = 0 ) |
calculate the normalmap as the 3d-vectors set
dest | the destination 3d-field |
heightmod | the modulator for the heightmap |
channel | the channel to be used as the depth source |
void ValuesField::operate | ( | const std::function< void(int, int) > & | f, |
bool | multithread = true ) |
operate over the field with the lambda
f | the lambda |
void ValuesField::operator*= | ( | float | value | ) |
multiply on the constant
value | the multiplicator |
void ValuesField::operator+= | ( | const ValuesField & | field | ) |
add field to the current
field | the field to add (same dimensions) |
void ValuesField::operator+= | ( | float | value | ) |
add the constant value to the field
value | the value to add |
void ValuesField::operator-= | ( | const ValuesField & | field | ) |
subtract field from the current
field | the subtracted field, same dimensions required |
void ValuesField::operator-= | ( | float | value | ) |
subtract the value from the field
value | the value to subtract |
void ValuesField::operator/= | ( | float | value | ) |
divide on the constant
value | the divider |
void ValuesField::recoverBump | ( | ValuesField & | dest | ) |
recover the bump from the color/greyscale (heuristic)
dest | the destination depthmap |
void ValuesField::rect | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
const cVec4 & | color ) |
draw the filled rectangle
x0 | the left-top corner x |
y0 | the left-top corner y |
x1 | the right-bottom corner x |
y1 | the right-bottom corner y |
color | the color of the rectangle (r, g, b a), all values are in [0..255] |
void ValuesField::relax | ( | ValuesField & | destination, |
float | degree, | ||
float | radius ) |
relax the field
destination | the destination field. It is recommended to use swap for multiple relax steps |
degree | the degree of the relaxation |
radius | the radius of the kernel |
void ValuesField::resizeTo | ( | ValuesField & | dest | ) |
resize the field to other size using the bicubic interpolation
dest | the destination field |
void ValuesField::saveImage | ( | const char * | name | ) |
save the field directly to file
name | the filename |
void ValuesField::set | ( | float | value, |
int | x, | ||
int | y, | ||
int | channel = 0 ) |
set teh value to the field
value | the value to set |
x | x-coordinate |
y | y-coordinate |
channel | the channel |
void ValuesField::setClampMode | ( | FieldClamp | cl | ) |
set the field clamp mode - how it acts beyond the boundaries
cl | the clamp mode - fcWrap, fcClamp or fcZero |
void ValuesField::sharp2X | ( | ValuesField & | dest | ) |
Experimental: Increase the image 2X and sharpen.
dest | the destination, should be empty |
void ValuesField::sharpEdges2X | ( | ValuesField & | dest | ) |
Experimental: Increase the image 2X and sharpen (sharpening edges so that edge width will be kept despite on the image size increasing)
dest | the destination, should be empty |
void ValuesField::sharpEdges2X1 | ( | ValuesField & | dest | ) |
Experimental, variation of the previous function: Increase the image 2X and sharpen (sharpening edges so that edge width will be kept despite on the image size increasing)
dest | the destination, should be empty |
void ValuesField::sharpen | ( | ValuesField & | destination, |
float | degree, | ||
float | radius ) |
sharpen the field
destination | the destination field. It is recommended to use swap for multiple relax steps |
degree | the degree of the relaxation |
radius | the radius of the kernel |
void ValuesField::sharpResize | ( | ValuesField & | dest, |
float | scale ) |
resize to bigger size keeping the edges sharpness
dest | destination image |
scale | the scale > 1 |
void ValuesField::swap | ( | ValuesField & | dest | ) |
swap two fields (dimensions may be different)
dest | the other field |
void ValuesField::toImage | ( | comms::cImage & | im | ) |
convert the field to the image
im | destination image, values should be 0..255 fro 3 or 4 cannels field, if there is 1 channel, the values will be scaled from minimum to maximum in range 0..255 |
void ValuesField::toPower2 | ( | ValuesField & | dest | ) |
resize to the closest power of 2 (may increase, may decrease the size, we choose what is arithmetically closer)
dest | the destination |
bool ValuesField::torange | ( | int & | x, |
int & | y ) const |
converts the (x,y) to range [0..Lx-1, 0..Ly-1]
x | x-coordinate |
y | y-coordinate |
float & ValuesField::value | ( | int | x, |
int | y, | ||
int | channel = 0 ) |
get the value reference of the field by the integer coordinates
x | x-coordinate |
y | y-coordinate |
channel | the channel |
|
inline |
get width