edflow.data.util package¶
Submodules:
Summary¶
Reference¶
-
edflow.data.util.
flow2hsv
(flow)[source]¶ Given a Flowmap of shape
[W, H, 2]
calculates an hsv image, showing the relative magnitude and direction of the optical flow.- Parameters
flow (np.array) – Optical flow with shape
[W, H, 2]
.- Returns
Containing the hsv data.
- Return type
np.array
-
edflow.data.util.
cart2polar
(x, y)[source]¶ Takes two array as x and y coordinates and returns the magnitude and angle.
-
edflow.data.util.
hsv2rgb
(hsv)[source]¶ color space conversion hsv -> rgb. simple wrapper for nice name.
-
edflow.data.util.
flow2rgb
(flow)[source]¶ converts a flow field to an rgb color image.
- Parameters
flow (np.array) – optical flow with shape
[W, H, 2]
.- Returns
Containing the rgb data. Color indicates orientation, intensity indicates magnitude.
- Return type
np.array
-
edflow.data.util.
get_support
(image)[source]¶ … warning: This function makes a lot of assumptions that need not be met!
Assuming that there are three categories of images and that the image_array has been properly constructed, this function will estimate the support of the given
image
.- Parameters
image (np.ndarray) – Some properly constructed image like array. No assumptions need to be made about the shape of the image, we simply assme each value is some color value.
- Returns
The support. Either ‘0->1’, ‘-1->1’ or ‘0->255’
- Return type
str
-
edflow.data.util.
sup_str_to_num
(support_str)[source]¶ Converts a support string into usable numbers.
-
edflow.data.util.
adjust_support
(image, future_support, current_support=None, clip=False)[source]¶ Will adjust the support of all color values in
image
.- Parameters
image (np.ndarray) – Array containing color values. Make sure this is properly constructed.
future_support (str) – The support this array is supposed to have after the transformation. Must be one of ‘-1->1’, ‘0->1’, or ‘0->255’.
current_support (str) – The support of the colors currentl in
image
. If not given it will be estimated byget_support()
.clip (bool) – By default the return values in image are simply coming from a linear transform, thus the actual support might be larger than the requested interval. If set to
True
the returned array will be cliped tofuture_support
.
- Returns
The given
image
with transformed support.- Return type
same type as image
-
edflow.data.util.
im_fn
(key, im, ax)[source]¶ Plot an image. Used by
plot_datum()
.
-
edflow.data.util.
heatmap_fn
(key, im, ax)[source]¶ Assumes that heatmap shape is [H, W, N]. Used by
plot_datum()
.
-
edflow.data.util.
flow_fn
(key, im, ax)[source]¶ Plot an flow. Used by
plot_datum()
.
-
edflow.data.util.
other_fn
(key, obj, ax)[source]¶ Print some text about the object. Used by
plot_datum()
.
-
edflow.data.util.
default_heuristic
(key, obj)[source]¶ Determines the kind of an object. Used by
plot_datum()
.
-
edflow.data.util.
plot_datum
(nested_thing, savename='datum.png', heuristics=<function default_heuristic>, plt_functions={'flow': <function flow_fn>, 'heat': <function heatmap_fn>, 'image': <function im_fn>, 'keypoints': <function keypoints_fn>, 'other': <function other_fn>})[source]¶ Plots all data in the nested_thing as best as can.
If heuristics is given, this determines how each leaf datum is converted to something plottable.
- Parameters
nested_thing (dict or list) – Some nested object.
savename (str) –
Path/to/the/plot.png
.heuristics (Callable) – If given this should produce a string specifying the kind of data of the leaf. If
None
determinde automatically. Seedefault_heuristic()
.plt_functions (dict of Callables) – Maps a
kind
to a function which can plot it. Each callable must be able to receive a the key, the leaf object and the Axes to plot it in.