3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ValuesField Class Reference

The class to operate over the 2D fields. More...

#include <ValuesField.h>

Public Member Functions

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
 
int width ()
 get width
 
int height ()
 get height
 
int depth ()
 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(2.0f/9.0f, 6.0f/9.0f, 1.0f/9.0f))
 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
 
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
 
cVec2getV2 (int x, int y)
 get the reference to the values as 2d - vector. It has sense only if there are at least 2 channels
 
float get_linear (float x, float y, int channel=0) const
 get the linearly interpolated value
 
cVec2 get_linearV2 (float x, float y)
 get the linearly interpolated value as 2d-vector
 
cVec3 get_linearV3 (float x, float y)
 get the linearly interpolated value as 3d-vector
 
cVec4 get_linearV4 (float x, float y)
 get the linearly interpolated value as 4d-vector
 
float get_bicubic (float x, float y, int channel=0) const
 get the bicubic interpolated value
 
cVec2 get_bicubicV2 (float x, float y)
 get the bicubic interpolated value as the 2d-vector
 
cVec3 get_bicubicV3 (float x, float y)
 get the bicubic interpolated value as the 3d-vector
 
cVec4 get_bicubicV4 (float x, float y)
 get the bicubic interpolated value as the 4d-vector
 
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 generatePerlin (float Sharpness)
 generate the perlin noise
 
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.
 
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)
 

Detailed Description

The class to operate over the 2D fields.

Member Function Documentation

◆ add()

void ValuesField::add ( float  value,
int  x,
int  y,
int  channel = 0 
)

add the value to the field

Parameters
valuethe value to add
xx-coordinate
yy-coordinate
channelthe channel

◆ create()

void ValuesField::create ( int  SizeX,
int  SiezY,
int  depth = 1,
FieldClamp  clampmode = fcWrap 
)

Create the field.

Parameters
SizeXwidth
SiezYheight
depthchannels count
clampmodeclamp mode

◆ createFromImage()

void ValuesField::createFromImage ( const comms::cImage &  im)

create the field form the image

Parameters
imthe image to be converted to the float field

◆ createFromImageMono()

void ValuesField::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)

Parameters
imthe image, if it is RGB, the channels will be merged to greyscale
maskthe mask to blend rgb - channels

◆ curvature()

void ValuesField::curvature ( ValuesField dest)

calculate the curvature of the 2d-field

Parameters
destthe destination field (1 channel)

◆ curvatureDir()

void ValuesField::curvatureDir ( ValuesField dest)

calculate the curvature principal directions

Parameters
destthe destination field (3channels)

◆ Decrease2X()

void ValuesField::Decrease2X ( ValuesField dest)

Decrease the field 2X times.

Parameters
destthe destination field

◆ depth()

int ValuesField::depth ( )
inline

Get amount of channels.

Returns
channels count

◆ generatePerlin()

void ValuesField::generatePerlin ( float  Sharpness)

generate the perlin noise

Parameters
Sharpnessthe sharpness of the noise

◆ get()

float ValuesField::get ( int  x,
int  y,
int  channel = 0 
) const

get the value of the field by the integer coordinates

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the value of the field

◆ get_bicubic()

float ValuesField::get_bicubic ( float  x,
float  y,
int  channel = 0 
) const

get the bicubic interpolated value

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated value

◆ get_bicubicV2()

cVec2 ValuesField::get_bicubicV2 ( float  x,
float  y 
)

get the bicubic interpolated value as the 2d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated value

◆ get_bicubicV3()

cVec3 ValuesField::get_bicubicV3 ( float  x,
float  y 
)

get the bicubic interpolated value as the 3d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated value

◆ get_bicubicV4()

cVec4 ValuesField::get_bicubicV4 ( float  x,
float  y 
)

get the bicubic interpolated value as the 4d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated value

◆ get_linear()

float ValuesField::get_linear ( float  x,
float  y,
int  channel = 0 
) const

get the linearly interpolated value

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated value reference

◆ get_linearV2()

cVec2 ValuesField::get_linearV2 ( float  x,
float  y 
)

get the linearly interpolated value as 2d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated 2d-value

◆ get_linearV3()

cVec3 ValuesField::get_linearV3 ( float  x,
float  y 
)

get the linearly interpolated value as 3d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated 2d-value

◆ get_linearV4()

cVec4 ValuesField::get_linearV4 ( float  x,
float  y 
)

get the linearly interpolated value as 4d-vector

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the interpolated 2d-value

◆ getV2()

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

Parameters
xx-coordinate
yy-coordinate
Returns
the reference to the vector

◆ getV3()

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

Parameters
xx-coordinate
yy-coordinate
Returns
the reference to the vector

◆ getV4()

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

Parameters
xx-coordinate
yy-coordinate
Returns
the reference to the 4d-vector

◆ gradientValue()

void ValuesField::gradientValue ( ValuesField dest)

calculate the gradient length

Parameters
destthe 1d field

◆ height()

int ValuesField::height ( )
inline

get height

Returns
height of the field

◆ LaplacianInterpolate() [1/2]

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.

Parameters
linesthe pairs of points that define the field, x,y of each point may be not integer, the count of points should be even

◆ LaplacianInterpolate() [2/2]

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.

Parameters
fixedThe fixel points falgs, fixed.get(x+y*width) == true means that point is fixed

◆ loadImage()

void ValuesField::loadImage ( const char *  name)

read the image directly from the file

Parameters
namethe filename

◆ max()

void ValuesField::max ( ValuesField other)

calculated the maximum of two fields into hte current

Parameters
otherthe other field

◆ monoTo()

void ValuesField::monoTo ( ValuesField dest)

convert multiple channels to one as an average-arithmetic

Parameters
dest

◆ NormalizeColors()

void ValuesField::NormalizeColors ( bool  monochromatic = false,
int  mipsize = 64 
)

Normalize the texture to be (128, 128, 128) in average using the mip-mapping algorithm.

Parameters
monochromaticset true to change the brightness only
mipsizethe mip-map size to be used to normalize the color

◆ normalmap()

void ValuesField::normalmap ( ValuesField dest,
int  byChannel = 0 
)

calculate the normalmap

Parameters
destthe destination field (2 channels, only dx and dy will be written)
byChannelthe channel to be used as the depth source

◆ normalmap3()

void ValuesField::normalmap3 ( ValuesField dest,
float  heightmod = 1.0,
int  channel = 0 
)

calculate the normalmap as the 3d-vectors set

Parameters
destthe destination 3d-field
heightmodthe modulator for the heightmap
channelthe channel to be used as the depth source

◆ operate()

void ValuesField::operate ( const std::function< void(int, int) > &  f,
bool  multithread = true 
)

operate over the field with the lambda

Parameters
fthe lambda

◆ operator*=()

void ValuesField::operator*= ( float  value)

multiply on the constant

Parameters
valuethe multiplicator

◆ operator+=() [1/2]

void ValuesField::operator+= ( const ValuesField field)

add field to the current

Parameters
fieldthe field to add (same dimensions)

◆ operator+=() [2/2]

void ValuesField::operator+= ( float  value)

add the constant value to the field

Parameters
valuethe value to add

◆ operator-=() [1/2]

void ValuesField::operator-= ( const ValuesField field)

subtract field from the current

Parameters
fieldthe subtracted field, same dimensions required

◆ operator-=() [2/2]

void ValuesField::operator-= ( float  value)

subtract the value from the field

Parameters
valuethe value to subtract

◆ operator/=()

void ValuesField::operator/= ( float  value)

divide on the constant

Parameters
valuethe divider

◆ recoverBump()

void ValuesField::recoverBump ( ValuesField dest)

recover the bump from the color/greyscale (heuristic)

Parameters
destthe destination depthmap

◆ relax()

void ValuesField::relax ( ValuesField destination,
float  degree,
float  radius 
)

relax the field

Parameters
destinationthe destination field. It is recommended to use swap for multiple relax steps
degreethe degree of the relaxation
radiusthe radius of the kernel

◆ resizeTo()

void ValuesField::resizeTo ( ValuesField dest)

resize the field to other size using the bicubic interpolation

Parameters
destthe destination field

◆ saveImage()

void ValuesField::saveImage ( const char *  name)

save the field directly to file

Parameters
namethe filename

◆ set()

void ValuesField::set ( float  value,
int  x,
int  y,
int  channel = 0 
)

set teh value to the field

Parameters
valuethe value to set
xx-coordinate
yy-coordinate
channelthe channel

◆ setClampMode()

void ValuesField::setClampMode ( FieldClamp  cl)

set the field clamp mode - how it acts beyond the boundaries

Parameters
clthe clamp mode - fcWrap, fcClamp or fcZero

◆ sharp2X()

void ValuesField::sharp2X ( ValuesField dest)

Experimental: Increase the image 2X and sharpen.

Parameters
destthe destination, should be empty

◆ sharpEdges2X()

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)

Parameters
destthe destination, should be empty

◆ sharpEdges2X1()

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)

Parameters
destthe destination, should be empty

◆ sharpen()

void ValuesField::sharpen ( ValuesField destination,
float  degree,
float  radius 
)

sharpen the field

Parameters
destinationthe destination field. It is recommended to use swap for multiple relax steps
degreethe degree of the relaxation
radiusthe radius of the kernel

◆ sharpResize()

void ValuesField::sharpResize ( ValuesField dest,
float  scale 
)

resize to bigger size keeping the edges sharpness

Parameters
destdestination image
scalethe scale > 1

◆ swap()

void ValuesField::swap ( ValuesField dest)

swap two fields (dimensions may be different)

Parameters
destthe other field

◆ toImage()

void ValuesField::toImage ( comms::cImage &  im)

convert the field to the image

Parameters
imdestination 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

◆ toPower2()

void ValuesField::toPower2 ( ValuesField dest)

resize to the closest power of 2 (may increase, may decrease the size, we choose what is arithmetically closer)

Parameters
destthe destination

◆ torange()

bool ValuesField::torange ( int &  x,
int &  y 
) const

converts the (x,y) to range [0..Lx-1, 0..Ly-1]

Parameters
xx-coordinate
yy-coordinate
Returns
true if succeed and wrapping happened

◆ value()

float & ValuesField::value ( int  x,
int  y,
int  channel = 0 
)

get the value reference of the field by the integer coordinates

Parameters
xx-coordinate
yy-coordinate
channelthe channel
Returns
the value of the field

◆ width()

int ValuesField::width ( )
inline

get width

Returns
width of the field

The documentation for this class was generated from the following file: