| Top |
| gboolean | gwy_nield_isolate () |
| gboolean | gwy_nield_isolate_at () |
| gboolean | gwy_nield_clear_at () |
| void | gwy_nield_clear_by_number () |
| void | gwy_nield_clear_by_size () |
| void | gwy_nield_clear_touching_border () |
| void | gwy_nield_mark_by_threshold () |
| void | gwy_nield_mark_range () |
| void | gwy_nield_union () |
| void | gwy_nield_intersect () |
| void | gwy_nield_merge () |
| void | gwy_nield_invert () |
| gboolean | gwy_nield_autocrop () |
| gint | gwy_nield_compactify () |
| gboolean | gwy_nield_flatten () |
| gint | gwy_nield_number_contiguous () |
| gint | gwy_nield_number_contiguous_periodic () |
| gint | gwy_nield_split_noncontiguous () |
| gint * | gwy_nield_grain_numbers () |
| guint * | gwy_nield_sizes () |
| gboolean | gwy_nield_fill_voids () |
gboolean gwy_nield_isolate (GwyNield *nield,gint number,gint *bbox);
Clears all numbers in a number field except one.
The result is flattened, i.e. all values become either 1 (marked) or 0 (outside).
See gwy_nield_isolate_at() for a function which isolates a contiguous region.
See gwy_nield_bounding_boxes() for bounding box representation. If there are no non-zero pixels at the end,
bbox
is filled with values corresponding to a non-existent grain.
gboolean gwy_nield_isolate_at (GwyNield *nield,gint col,gint row,gint *bbox);
Isolates a contiguous region at given location in a number field.
The result is flattened, i.e. all values become either 1 (marked) or 0 (outside).
The region is defined by being both contiguous and having the same non-zero number as at (col
,row
). If the value
at (col
,row
) is not positive, the number field is cleared.
See gwy_nield_isolate() for a function that isolates a possibly non-contiguous region by grain number and can be
used to isolate a non-contiguous grain by postion (just read the value at (col
, row
)). If you instead want to
isolate a contiguous marked region regardless of the grain number, use gwy_nield_flatten() first.
See gwy_nield_bounding_boxes() for bounding box representation. If there are no non-zero pixels at the end,
bbox
is filled with values corresponding to a non-existent grain.
gboolean gwy_nield_clear_at (GwyNield *nield,gint col,gint row);
Clears a contiguous region at given location in a number field.
The region is defined by being both contiguous and having the same non-zero number as at (col
,row
). If the value
at (col
,row
) is not positive, the function is no-op.
See gwy_nield_clear_by_number() for a function which clears a possibly non-contiguous region by grain number. If
you want to clear a contiguous marked region regardless of the grain number, use gwy_nield_flatten() first.
void gwy_nield_clear_by_number (GwyNield *nield,gint number,gboolean compactify);
Clears a single grain in a number field, given by number.
If compactify
is FALSE, there will be a hole in the grain numbers. Passing TRUE moves larger grain numbers down
by one. However, this only removes the newly created hole in numbers, not any pre-existing ones. Use
gwy_nield_compactify() to remove all holes in grain numbers.
void gwy_nield_clear_by_size (GwyNield *nield,gint size);
Clears all grains below specified area in a number field.
All numbered regions with total pixel area smaller than size
are filled with 0.
Grain numbers are not modified, so holes in grain numbers are likely to occur. Use gwy_nield_compactify() to
remove the holes if it matters.
void gwy_nield_clear_touching_border (GwyNield *nield,gboolean completely);
Clears all grains that touch any of a number field's borders.
Grain numbers are not modified, so holes in grain numbers are likely to occur. Use gwy_nield_compactify() to
remove the holes if it matters.
void gwy_nield_mark_by_threshold (GwyNield *nield,GwyField *field,gdouble threshold,gboolean above);
Marks all values in a data field based on a global threshold.
If above
is TRUE, values ≤ threshold
are marked. Otherwise values ≥ threshold
are marked. Values equal to the
threshold are marked in both cases.
See also gwy_nield_mark_range() for marking a range of values.
void gwy_nield_mark_range (GwyNield *nield,GwyField *field,gdouble lower,gdouble upper);
Marks all values in a data field within (or outside) an interval.
If lower
≤ upper
, field
values in the closed interval [lower
, upper
] are marked in nield
with 1, the rest
marked with 0.
If lower
> upper
, field
values in the two closed intervals [-∞, lower
] and [upper
, ∞] are marked in nield
with 1, the rest marked with 0. The closed intervals should be read as all ‘values ≤ lower
’ and ‘values ≥ upper
’.
See also gwy_nield_mark_range() for marking using a single threshold and gwy_field_mark_outliers2() and
gwy_field_mark_outliers_iqr() for outlier marking.
void gwy_nield_union (GwyNield *nield,GwyNield *union_with);
Combines two number fields by grain union.
More precisely, the resulting numbers are the maxima of the two inputs. The result is not renumbered in any
manner. Although this is valid when just distinguishing marked and empty regions, often you will want to apply
gwy_nield_number_contiguous() or gwy_nield_flatten() aftewards.
void gwy_nield_intersect (GwyNield *nield,GwyNield *intersect_with);
Combines two number fields by grain intersection.
More precisely, the resulting numbers are the minima of the two inputs. The result is not renumbered in any
manner. Although this is valid when just distinguishing marked and empty regions, often you will want to apply
gwy_nield_number_contiguous() or gwy_nield_flatten() aftewards.
void gwy_nield_merge (GwyNield *nield,GwyNield *operand,GwyMergeType operation);
Combines two number fields by grain logical operation.
The function is a shorthand for doing either gwy_nield_union() or gwy_nield_intersect() depending on a
GwyMergeType setting. If operand
is NULL, nield
is left unmodified.
Value outside the enum are allowed as operation
, meaning to do nothing. However, GwyMergeType can be extended to
other logical operations, so you need to pass a value like -1 or G_MAXINT.
void
gwy_nield_invert (GwyNield *nield);
Swaps marked and empty regions in a number field.
The result is flattened. All previously empty pixels are set to 1 and all previously marked to 0.
gboolean gwy_nield_autocrop (GwyNield *nield,gboolean symmetrically,guint *left,guint *right,guint *up,guint *down);
Removes empty border rows and columns from a number field.
If there are border rows and columns filled completely with non-positive values the size of the data field is
reduced, removing these rows or columns. Parameter symmetrically
controls whether the size reduction is maximum
possible or symmetrical.
When there is no positive value in the field the field size is reduced to the smallest possible. It means 1×1 for
symmetrical
being FALSE or odd original dimensions. If the original dimensions are even and symmetrical
TRUE,
only the field is reduced to 2×2.
nield |
A number field. |
|
symmetrically |
|
|
left |
Location to store how many column were removed from the left, or |
[out][optional] |
right |
Location to store how many column were removed from the right, or |
[out][optional] |
up |
Location to store how many row were removed from the top, or |
[out][optional] |
down |
Location to store how many row were removed from the bottom, or |
[out][optional] |
gint
gwy_nield_compactify (GwyNield *nield);
Compactifies the numbering of marked regions in a number field.
Positive grain numbers will form an uninterrupted sequence from 1 to the return value. This is useful for removing holes in grain numbers. Non-positive values are unchanged by this function.
gboolean
gwy_nield_flatten (GwyNield *nield);
Flattens all values in a number field to 0 or 1.
gint
gwy_nield_number_contiguous (GwyNield *nield);
Renumbers regions in a number field based on contiguity.
Each distinct 4-connected region will have a unique number, and these will form an uninterrputed sequence starting from 1. Non-positive values are unchanged.
gint
gwy_nield_number_contiguous_periodic (GwyNield *nield);
Renumbers regions in a number field based on periodic contiguity.
An alternative version of gwy_nield_number_contiguous() which considers the number field as peroidic in the plane,
i.e. grains can also connect through the opposite edges.
gint
gwy_nield_split_noncontiguous (GwyNield *nield);
Splits regions in a number field based on contiguity.
Numbered regions formed by multiple disconnected parts are split, giving each part a distinct number. Touching
regions with distinct numbers are not merged; use gwy_nield_number_contiguous() if you want also merging, not just
splitting. Non-positive values are unchanged.
gint * gwy_nield_grain_numbers (GwyNield *nield,gint *ngrains);
Gets all the distinct positive grain numbers in a number field.
guint * gwy_nield_sizes (GwyNield *nield,gint *maxgno);
Computes the numbers of pixels of all grains in a number field.
The zeroth element of the returned array does not correspond to any grain; grain numbers start from 1.
gboolean gwy_nield_fill_voids (GwyNield *nield,gboolean nonsimple);
Fills voids in grains in a number field.
Voids are regions of non-positive numbers in nield
from which no path exists through other non-positive values to
the number field boundary. The paths are considered in 8-connectivity because grains themselves are considered in
4-connectivity.
When nonsimple
is FALSE, the total number of grains dos not change, only grain areas. When it is TRUE, some
grains may disappear. In either case, the function does not attempt to produce any reasonable grain numbering.
The result works as a mask, but needs renumbering for any grain operation.
Mask merge type (namely used in grain processing).
|
Zero, disregarding both operands. |
||
|
Intersection (logical-and/minimum) merging. |
||
|
Alternative name for |
||
|
Alternative name for |
||
|
Subtraction (clearing the first operand where the second is set). |
||
|
Values are given by the first operand. |
||
|
Reverse subtraction (second operand, except where the first is set). |
||
|
Values are given by the second operand. |
||
|
Exclusive or merging (if exactly one operand is set, keeping this one). |
||
|
Union (logical-or/maximum) merging. |
||
|
Alternative name for |
||
|
Alternative name for |
||
|
Alternative name for |
||
|
Positive only if both operands are unset. |
||
|
Alternative name for |
||
|
Positive where both operands are set or both unset (if they are both positive, the value is kept). |
||
|
Values are given by the negation of the second operand. |
||
|
Positive except when the first operand is set and the second unset. |
||
|
Values are given by the negation of the first operand. |
||
|
Positive except when the second operand is set and the first unset. |
||
|
Positive only if either operand is unset. |
||
|
Set, disregarding both operands. |