| Top |
| GwyNield * | gwy_nield_new () |
| GwyNield * | gwy_nield_new_alike () |
| GwyNield * | gwy_nield_copy () |
| void | gwy_nield_assign () |
| void | gwy_nield_invalidate () |
| void | gwy_nield_data_changed () |
| void | gwy_nield_resize () |
| void | gwy_nield_crop () |
| GwyNield * | gwy_nield_area_extract () |
| void | gwy_nield_copy_data () |
| void | gwy_nield_area_copy () |
| gint * | gwy_nield_get_data () |
| const gint * | gwy_nield_get_data_const () |
| gint | gwy_nield_get_xres () |
| gint | gwy_nield_get_yres () |
| gint | gwy_nield_max () |
| gint | gwy_nield_get_val () |
| void | gwy_nield_set_val () |
| GwyNield * | gwy_nield_new_rotated_90 () |
| void | gwy_nield_flip () |
| void | gwy_nield_transpose () |
| void | gwy_nield_area_transpose () |
| void | gwy_nield_fill () |
| void | gwy_nield_area_fill () |
| void | gwy_nield_clear () |
| void | gwy_nield_area_clear () |
| guint | gwy_nield_count () |
| guint | gwy_nield_area_count () |
GwyNield is a regular two-dimensional data array of natural (or whole) numbers. It represents the result of some classification of two-dimensional data. The uses vary from a simple 0/1 masking to complicated splitting to multiple regions. Usually, zero means empty space and positive numbers marked regions. Occasionally, negative values are used to distinguish different types of empty space.
Unlike GwyField, GwyNield does not have units or physical dimensions. It is just a matrix of integers.
GwyNield * gwy_nield_new (gint xres,gint yres);
Creates a new number field.
The field is created as zero-filled.
[constructor]
GwyNield *
gwy_nield_new_alike (GwyNield *model);
Creates a new number field similar to an existing one.
The field is created as zero-filled. Use gwy_nield_copy() if you want to copy a number field including data.
GwyNield *
gwy_nield_copy (GwyNield *nield);
Create a new number field as a copy of an existing one.
This function is a convenience gwy_serializable_copy() wrapper.
void gwy_nield_assign (GwyNield *destination,GwyNield *source);
Makes one number field equal to another.
This function is a convenience gwy_serializable_assign() wrapper.
void
gwy_nield_invalidate (GwyNield *nield);
Invalidates cached number field stats.
User code should rarely need this macro, as all GwyNield methods do proper invalidation when they change data,
as well as gwy_nield_get_data() does.
However, if you get raw data with gwy_nield_get_data() and then mix direct changes to it with calls to methods
like gwy_nield_max(), you may need to explicitely invalidate cached values to let gwy_nield_get_max()
know it has to recompute the maximum.
void
gwy_nield_data_changed (GwyNield *nield);
Emits signal "data-changed" on a number field.
void gwy_nield_resize (GwyNield *nield,gint xres,gint yres);
Resizes a number field.
The content becomes undefined and the raw data returned by gwy_nield_get_data() may become invalid pointer.
void gwy_nield_crop (GwyNield *nield,gint col,gint row,gint width,gint height);
Crops a number field to a smaller size.
GwyNield * gwy_nield_area_extract (GwyNield *nield,gint col,gint row,gint width,gint height);
Extracts a rectangular part of a number field to a new number field.
void gwy_nield_copy_data (GwyNield *nield,GwyNield *target);
Copies the contents of an already allocated number field to a number field of the same size.
Only the data are copied. To make a number field completely identical to another, including units and change of
dimensions, you can use gwy_nield_assign().
void gwy_nield_area_copy (GwyNield *src,GwyNield *dest,gint col,gint row,gint width,gint height,gint destcol,gint destrow);
Copies a rectangular area from one number field to another.
The area starts at (col
, row
) in src
and its dimension is width
*height
. It is copied to dest
starting from
(destcol
, destrow
).
The source area has to be completely contained in src
. No assumptions are made about destination position,
however, parts of the source area sticking out the destination number field dest
are cut off.
If src
is equal to dest
, the areas may not overlap.
src |
Source number field. |
|
dest |
Destination number field. |
|
col |
Area upper-left column coordinate in |
|
row |
Area upper-left row coordinate |
|
width |
Area width (number of columns), pass -1 for full |
|
height |
Area height (number of rows), pass -1 for full |
|
destcol |
Destination column in |
|
destrow |
Destination row in |
gint *
gwy_nield_get_data (GwyNield *nield);
Gets the raw data buffer of a number field.
The returned buffer is not guaranteed to be valid through whole number field life time. Some function may change
it, most notably gwy_nield_resize() and gwy_nield_crop().
This function invalidates any cached information, use gwy_nield_get_data_const() if you are not going to
change the data.
See gwy_nield_invalidate() for some discussion.
The number field as a pointer to an array of gwy_nield_get_xres()*gwy_nield_get_yres() gint's,
ordered by lines. I.e., they are to be accessed as data[row*xres + column].
const gint *
gwy_nield_get_data_const (GwyNield *nield);
Gets the raw data buffer of a number field, read-only.
The returned buffer is not guaranteed to be valid through whole number field life time. Some function may change it,
most notably gwy_nield_resize() and gwy_nield_crop().
Use gwy_nield_get_data() if you want to change the data.
See gwy_nield_invalidate() for some discussion.
The number field as a pointer to an array of gwy_nield_get_xres()*gwy_nield_get_yres() gint's,
ordered by lines. I.e., they are to be accessed as data[row*xres + column].
gint
gwy_nield_get_xres (GwyNield *nield);
Gets X resolution (number of columns) of a number field.
gint
gwy_nield_get_yres (GwyNield *nield);
Gets Y resolution (number of rows) of the field.
gint gwy_nield_get_val (GwyNield *nield,gint col,gint row);
Gets value at given position in a number field.
Do not access data with this function inside inner loops, it's slow. Get the raw data buffer with
gwy_nield_get_data_const() and access it directly instead.
void gwy_nield_set_val (GwyNield *nield,gint col,gint row,gint value);
Sets value at given position in a number field.
Do not set data with this function inside inner loops, it's slow. Get the raw data buffer with
gwy_nield_get_data() and write to it directly instead.
GwyNield * gwy_nield_new_rotated_90 (GwyNield *nield,gboolean clockwise);
Creates a new number field by rotating a number field by 90 degrees.
void gwy_nield_flip (GwyNield *nield,gboolean xflipped,gboolean yflipped);
Reflects a number field.
void gwy_nield_transpose (GwyNield *src,GwyNield *dest,gboolean minor);
Copies data from one number field to another with transposition.
The destination number field is resized as necessary.
void gwy_nield_area_transpose (GwyNield *src,gint col,gint row,gint width,gint height,GwyNield *dest,gboolean minor);
Copies data from a rectangular part of one number field to another with transposition.
The destination number field is resized as necessary.
src |
Source number field. |
|
col |
Upper-left column coordinate in |
|
row |
Upper-left row coordinate in |
|
width |
Area width (number of columns) in |
|
height |
Area height (number of rows) in |
|
dest |
Destination number field. |
|
minor |
|
void gwy_nield_fill (GwyNield *nield,gint value);
Fills a number field with given value.
void gwy_nield_area_fill (GwyNield *nield,GwyNield *mask,GwyMaskingType mode,gint col,gint row,gint width,gint height,gint value);
Fills a masked rectangular part of a number field with given value.
nield |
A number field. |
|
mask |
Mask specifying which values to take into account/exclude, or |
|
mode |
Masking mode to use. See the introduction for description of masking modes. |
|
col |
Upper-left column coordinate. |
|
row |
Upper-left row coordinate. |
|
width |
Area width (number of columns). |
|
height |
Area height (number of rows). |
|
value |
Value to be entered |
void gwy_nield_area_clear (GwyNield *nield,gint col,gint row,gint width,gint height);
Fills a rectangular part of a number field with zeroes.
Use gwy_nield_area_fill() to clear an area with masking. Clearing is only more efficient without masking.
guint
gwy_nield_count (GwyNield *nield);
Counts positive values in a number field.
guint gwy_nield_area_count (GwyNield *nield,GwyNield *mask,GwyMaskingType mode,gint col,gint row,gint width,gint height);
Counts positive values in a rectangular region of a number field.
nield |
A number field. |
|
mask |
Mask specifying which values to take into account/exclude, or |
|
mode |
Masking mode to use. See the introduction for description of masking modes. |
|
col |
Upper-left column coordinate. |
|
row |
Upper-left row coordinate. |
|
width |
Area width (number of columns). |
|
height |
Area height (number of rows) |
“data-changed” signalvoid user_function (GwyNield *gwynield, gpointer user_data)
The ::data-changed signal is never emitted by number field itself. It is intended as a means to notify others number field users they should update themselves.
gwynield |
The GwyNield which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First