Common
This module contains relevant structures and functions for manipulating data. These structures are either for coordinate manipulation,
relationship of structures (Graph), color information, etc.
Structures
Data types
Yayi handles a large amount of data types, where handling here mainly means the type of pixels supported for images. A data type is composed of
two fields:
Coordinates
Coordinates in Yayi are tuples of lists. The length of the sequence defines the dimension in with the coordinate is expressed.
For instance, 2D coordinates and rectangles are defines like this:
coord1 = (10, 20)
coord2 = (30, 40)
rect2D = YayiCommonPython.HyperRectangle(coord1, coord2)
The YayiCommonPython.HyperRectangle structure is, as its name indicates, a rectangle (or bounding box) in any dimension. It is defined by its two extremal corners.
Some functions are available for manipulating coordinates and collection of coordinates:
Graphs
Graphs are made of vertices and undirected edges (current implementation, may change in the future). The graphs in Yayi cannot
contain parallel edges. A property can be associated to each vertex and each Edge.
Graphs in Yayi are used for manipulating regions in images and their adjacencies.
Color manipulation
Yayi can handle different color spaces. The color spaces are encoded in a particular structure: colorspace.
The color space transformations are pixel-to-pixel transformations that are available in the Pixel processing module.
Histograms
Histograms in Yayi are handled through dictionaries.
Examples
Coordinates
The following code generates randomly one set of coordinates and creates a second bigger set containing a permutation of the first set.
Then, sets are tested for equality:
# importing the module containing the utilities
from Yayi.YAYI import COM as YCOM
import random
# generates random coordinates
set1 = [(random.randint(0, 20), random.randint(0, 30)) for i in range(30)]
# generates a random sample
# we should have len(set(set1) - set(set2)) == 0
set2 = random.sample(set1, len(set1))
# we add existing points, we still have len(set(set1) - set(set2)) == 0
set2.extend(random.sample(set1, len(set1)/3))
# testing if the two previous sets contain the same elements
if(YCOM.AreSetOfPointsEqual(set1, set2)):
print "The two sets contains the same points"
set2.append(YCOM.Transpose(set2[-1]))
if(not YCOM.AreSetOfPointsEqual(set1, set2)):
print "Sets are different"
Graphs
Reference
-
YayiCommonPython.AreSetOfPointsEqual((object)set1, (object)set2) → bool :
returns true if set1 and set2 contain the same points (with possible duplicate coordinates
- C++ signature :
- bool AreSetOfPointsEqual(boost::python::api::object,boost::python::api::object)
-
class YayiCommonPython.Edge
An edge structure with no property (for manipulation ease)
-
class YayiCommonPython.Graph((object)arg1)
Undirected graph structure that can be converted into a Yayi suitable format without parallel edges
-
add_edge((Graph)arg1, (int)v1, (int)v2, (HyperRectangle)edge_data) → Edge :
Adds an edge between vertices v1 and v2.
| Parameters: |
- v1 – source edge
- v2 – target edge
- edge_data – data associated to the edge
|
| Returns: | the created or existing edge from v1 to v2
|
- C++ signature :
- boost::detail::edge_desc_impl<boost::undirected_tag, unsigned long> add_edge(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long,unsigned long,yayi::s_any_type)
-
add_vertex((Graph)arg1) → int :
Adds a vertex to the graph.
| Returns: | index of the create vertex |
- C++ signature :
- unsigned long add_vertex(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue})
-
add_vertex_with_data((Graph)arg1, (HyperRectangle)data) → int :
Adds a vertex to the graph with data.
| Parameters: | data – any python object supported for storage, associated to the vertex |
| Returns: | index of the create vertex |
- C++ signature :
- unsigned long add_vertex_with_data(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},yayi::s_any_type)
-
are_vertices_adjacent((Graph)arg1, (int)arg2, (int)arg3) → bool :
returns whether there is an edge between two vertices without considering any directed property
- C++ signature :
- bool are_vertices_adjacent(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long,unsigned long)
-
clear((Graph)arg1) → None :
removes all edges, vertices and their associated data from the graph.
- C++ signature :
- void clear(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue})
-
get_edge((Graph)arg1, (int)arg2, (int)arg3) → Edge :
returns the edge connecting the two vertices
- C++ signature :
- boost::detail::edge_desc_impl<boost::undirected_tag, unsigned long> get_edge(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long,unsigned long)
-
get_edge_data((Graph)arg1, (Edge)arg2) → object :
returns the data associated to the argument edge
- C++ signature :
- yayi::s_any_type get_edge_data(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},boost::detail::edge_desc_impl<boost::undirected_tag, unsigned long>)
-
get_vertex_data((Graph)arg1, (int)arg2) → object :
returns the data associated by the argument vertex
- C++ signature :
- yayi::s_any_type get_vertex_data(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long)
-
is_directed
returns whether the graph is directed (currently only undirected)
-
num_adjacent_vertices((Graph)arg1, (int)arg2) → int :
returns the number of adjacent vertice to the provided vertex
- C++ signature :
- unsigned int num_adjacent_vertices(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long)
-
num_edges((Graph)arg1) → int :
number of edges of the graph.
- C++ signature :
- unsigned long num_edges(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue})
-
num_vertices((Graph)arg1) → int :
number of vertices of the graph.
- C++ signature :
- unsigned long num_vertices(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue})
-
remove_edge((Graph)arg1, (int)arg2, (int)arg3) → None :
removes an edge between vertices v1 and v2.
- C++ signature :
- void remove_edge(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long,unsigned long)
- remove_edge( (Graph)arg1, (Edge)arg2) -> None :
removes an edge by its descriptor.
- C++ signature :
- void remove_edge(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},boost::detail::edge_desc_impl<boost::undirected_tag, unsigned long>)
-
set_edge_data((Graph)arg1, (Edge)arg2, (HyperRectangle)arg3) → None :
sets the data associated to the argument edge
- C++ signature :
- void set_edge_data(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},boost::detail::edge_desc_impl<boost::undirected_tag, unsigned long>,yayi::s_any_type)
-
set_vertex_data((Graph)arg1, (int)arg2, (HyperRectangle)arg3) → None :
set the data associated by the argument vertex
- C++ signature :
- void set_vertex_data(yayi::s_graph<yayi::s_any_type, yayi::s_any_type, false, boost::vertex_name_t, boost::edge_weight_t> {lvalue},unsigned long,yayi::s_any_type)
-
class YayiCommonPython.HyperRectangle((object)arg1)
A generic rectangle structure in any dimension (lower bound and upper bound)
-
GetSize((HyperRectangle)arg1) → object :
Returns the size of the hyperrectangle
- C++ signature :
- yayi::s_coordinate<0, int> GetSize(yayi::s_hyper_rectangle<0> {lvalue})
-
IsInside((HyperRectangle)arg1, (object)arg2) → bool :
Tests if the provided point is inside the hyperrectangle
- C++ signature :
- bool IsInside(yayi::s_hyper_rectangle<0> {lvalue},yayi::s_coordinate<0, int>)
-
Origin
-
SetSize((HyperRectangle)arg1, (object)arg2) → None :
Sets the size of the hyperrectangle
- C++ signature :
- void SetSize(yayi::s_hyper_rectangle<0> {lvalue},yayi::s_coordinate<0, int>)
-
Size
-
upper_right
-
class YayiCommonPython.Object
An abstract object
-
Description((Object)arg1) → str :
description of the object
- C++ signature :
- std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Description(yayi::IObject {lvalue})
-
DynamicType((Object)arg1) → type :
type of the object
- C++ signature :
- yayi::s_type_description DynamicType(yayi::IObject {lvalue})
-
YayiCommonPython.Transpose((object)arg1) → object :
Coordinate transposition.
Transposition means that all coordinate dimensions are inverted, which is equivalent to a symmetry from the origin of the referential.
- C++ signature :
- yayi::s_coordinate<0, int> Transpose(yayi::s_coordinate<0, int>)
-
YayiCommonPython.TransposeWithCenter((object)arg1, (object)arg2) → object :
Coordinate transposition with a given center.
- C++ signature :
- yayi::s_coordinate<0, int> TransposeWithCenter(yayi::s_coordinate<0, int>,yayi::s_coordinate<0, int>)
-
YayiCommonPython.blackbody_radiation((int)arg1, (int)arg2) → float :
Returns the value of the black body radiator at the specified wavelength and temperature
- C++ signature :
- double blackbody_radiation(unsigned int,unsigned int)
-
YayiCommonPython.blackbody_radiation_normalized((int)arg1, (int)arg2, (int)arg3) → float :
Returns the value of the black body radiator at the specified wavelength and temperature, normalizedby the black body radiation value at the same wavelength and specified normalization temperature
- C++ signature :
- double blackbody_radiation_normalized(unsigned int,unsigned int,unsigned int)
-
class YayiCommonPython.colorspace((object)arg1)
-
illuminant
-
major
-
minor
-
primary
-
class YayiCommonPython.colorspace_major
-
cs_hls = YayiCommonPython.colorspace_major.cs_hls
-
cs_rgb = YayiCommonPython.colorspace_major.cs_rgb
-
cs_undefined = YayiCommonPython.colorspace_major.cs_undefined
-
cs_xyY = YayiCommonPython.colorspace_major.cs_xyY
-
cs_xyz = YayiCommonPython.colorspace_major.cs_xyz
-
cs_yuv = YayiCommonPython.colorspace_major.cs_yuv
-
names = {'cs_hls': YayiCommonPython.colorspace_major.cs_hls, 'cs_rgb': YayiCommonPython.colorspace_major.cs_rgb, 'cs_yuv': YayiCommonPython.colorspace_major.cs_yuv, 'cs_xyz': YayiCommonPython.colorspace_major.cs_xyz, 'cs_xyY': YayiCommonPython.colorspace_major.cs_xyY, 'cs_undefined': YayiCommonPython.colorspace_major.cs_undefined}
-
values = {0: YayiCommonPython.colorspace_major.cs_undefined, 1: YayiCommonPython.colorspace_major.cs_rgb, 2: YayiCommonPython.colorspace_major.cs_hls, 4: YayiCommonPython.colorspace_major.cs_xyz, 5: YayiCommonPython.colorspace_major.cs_xyY, 6: YayiCommonPython.colorspace_major.cs_yuv}
-
class YayiCommonPython.colorspace_minor
-
csm_hls_l1 = YayiCommonPython.colorspace_minor.csm_hls_l1
-
csm_hls_trig = YayiCommonPython.colorspace_minor.csm_hls_trig
-
csm_undefined = YayiCommonPython.colorspace_minor.csm_undefined
-
names = {'csm_hls_trig': YayiCommonPython.colorspace_minor.csm_hls_trig, 'csm_hls_l1': YayiCommonPython.colorspace_minor.csm_hls_l1, 'csm_undefined': YayiCommonPython.colorspace_minor.csm_undefined}
-
values = {0: YayiCommonPython.colorspace_minor.csm_undefined, 1: YayiCommonPython.colorspace_minor.csm_hls_l1, 2: YayiCommonPython.colorspace_minor.csm_hls_trig}
-
class YayiCommonPython.compound_type
-
c_3 = YayiCommonPython.compound_type.c_3
-
c_4 = YayiCommonPython.compound_type.c_4
-
c_complex = YayiCommonPython.compound_type.c_complex
-
c_container = YayiCommonPython.compound_type.c_container
-
c_coordinate = YayiCommonPython.compound_type.c_coordinate
-
c_function = YayiCommonPython.compound_type.c_function
-
c_generic = YayiCommonPython.compound_type.c_generic
-
c_image = YayiCommonPython.compound_type.c_image
-
c_iterator = YayiCommonPython.compound_type.c_iterator
-
c_map = YayiCommonPython.compound_type.c_map
-
c_scalar = YayiCommonPython.compound_type.c_scalar
-
c_structuring_element = YayiCommonPython.compound_type.c_structuring_element
-
c_unknown = YayiCommonPython.compound_type.c_unknown
-
c_variant = YayiCommonPython.compound_type.c_variant
-
c_vector = YayiCommonPython.compound_type.c_vector
-
names = {'c_generic': YayiCommonPython.compound_type.c_generic, 'c_coordinate': YayiCommonPython.compound_type.c_coordinate, 'c_container': YayiCommonPython.compound_type.c_container, 'c_function': YayiCommonPython.compound_type.c_function, 'c_structuring_element': YayiCommonPython.compound_type.c_structuring_element, 'c_3': YayiCommonPython.compound_type.c_3, 'c_scalar': YayiCommonPython.compound_type.c_scalar, 'c_map': YayiCommonPython.compound_type.c_map, 'c_iterator': YayiCommonPython.compound_type.c_iterator, 'c_4': YayiCommonPython.compound_type.c_4, 'c_complex': YayiCommonPython.compound_type.c_complex, 'c_variant': YayiCommonPython.compound_type.c_variant, 'c_unknown': YayiCommonPython.compound_type.c_unknown, 'c_image': YayiCommonPython.compound_type.c_image, 'c_vector': YayiCommonPython.compound_type.c_vector}
-
values = {0: YayiCommonPython.compound_type.c_unknown, 1: YayiCommonPython.compound_type.c_generic, 2: YayiCommonPython.compound_type.c_variant, 3: YayiCommonPython.compound_type.c_image, 4: YayiCommonPython.compound_type.c_iterator, 5: YayiCommonPython.compound_type.c_coordinate, 6: YayiCommonPython.compound_type.c_scalar, 7: YayiCommonPython.compound_type.c_complex, 8: YayiCommonPython.compound_type.c_3, 9: YayiCommonPython.compound_type.c_4, 10: YayiCommonPython.compound_type.c_vector, 11: YayiCommonPython.compound_type.c_map, 12: YayiCommonPython.compound_type.c_container, 13: YayiCommonPython.compound_type.c_function, 14: YayiCommonPython.compound_type.c_structuring_element}
-
YayiCommonPython.current_build_date() → tuple :
Returns the date of build as a tuple in the following format: (year, month, day, hour, minutes, seconds)
- C++ signature :
- boost::python::tuple current_build_date()
-
YayiCommonPython.current_build_version() → str :
Returns the current build version
- C++ signature :
- std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > current_build_version()
-
class YayiCommonPython.illuminant
-
ill_A = YayiCommonPython.illuminant.ill_A
-
ill_B = YayiCommonPython.illuminant.ill_B
-
ill_C = YayiCommonPython.illuminant.ill_C
-
ill_E = YayiCommonPython.illuminant.ill_E
-
ill_blackbody = YayiCommonPython.illuminant.ill_blackbody
-
ill_d50 = YayiCommonPython.illuminant.ill_d50
-
ill_d55 = YayiCommonPython.illuminant.ill_d55
-
ill_d65 = YayiCommonPython.illuminant.ill_d65
-
ill_d75 = YayiCommonPython.illuminant.ill_d75
-
ill_undefined = YayiCommonPython.illuminant.ill_undefined
-
names = {'ill_blackbody': YayiCommonPython.illuminant.ill_blackbody, 'ill_undefined': YayiCommonPython.illuminant.ill_undefined, 'ill_A': YayiCommonPython.illuminant.ill_A, 'ill_C': YayiCommonPython.illuminant.ill_C, 'ill_B': YayiCommonPython.illuminant.ill_B, 'ill_E': YayiCommonPython.illuminant.ill_E, 'ill_d50': YayiCommonPython.illuminant.ill_d50, 'ill_d55': YayiCommonPython.illuminant.ill_d55, 'ill_d65': YayiCommonPython.illuminant.ill_d65, 'ill_d75': YayiCommonPython.illuminant.ill_d75}
-
values = {0: YayiCommonPython.illuminant.ill_undefined, 1: YayiCommonPython.illuminant.ill_d50, 2: YayiCommonPython.illuminant.ill_d55, 3: YayiCommonPython.illuminant.ill_d65, 4: YayiCommonPython.illuminant.ill_d75, 5: YayiCommonPython.illuminant.ill_A, 6: YayiCommonPython.illuminant.ill_B, 7: YayiCommonPython.illuminant.ill_C, 8: YayiCommonPython.illuminant.ill_E, 9: YayiCommonPython.illuminant.ill_blackbody}
-
class YayiCommonPython.primaries
-
names = {'prim_SecamRGB': YayiCommonPython.primaries.prim_SecamRGB, 'prim_sRGB': YayiCommonPython.primaries.prim_sRGB, 'prim_AppleRGB': YayiCommonPython.primaries.prim_AppleRGB, 'prim_undefined': YayiCommonPython.primaries.prim_undefined, 'prim_NTSCRGB': YayiCommonPython.primaries.prim_NTSCRGB, 'prim_AdobeRGB': YayiCommonPython.primaries.prim_AdobeRGB, 'prim_CIE': YayiCommonPython.primaries.prim_CIE}
-
prim_AdobeRGB = YayiCommonPython.primaries.prim_AdobeRGB
-
prim_AppleRGB = YayiCommonPython.primaries.prim_AppleRGB
-
prim_CIE = YayiCommonPython.primaries.prim_CIE
-
prim_NTSCRGB = YayiCommonPython.primaries.prim_NTSCRGB
-
prim_SecamRGB = YayiCommonPython.primaries.prim_SecamRGB
-
prim_sRGB = YayiCommonPython.primaries.prim_sRGB
-
prim_undefined = YayiCommonPython.primaries.prim_undefined
-
values = {0: YayiCommonPython.primaries.prim_undefined, 1: YayiCommonPython.primaries.prim_CIE, 2: YayiCommonPython.primaries.prim_sRGB, 3: YayiCommonPython.primaries.prim_AdobeRGB, 4: YayiCommonPython.primaries.prim_AppleRGB, 5: YayiCommonPython.primaries.prim_NTSCRGB, 6: YayiCommonPython.primaries.prim_SecamRGB}
-
class YayiCommonPython.scalar_type
-
names = {'s_ui32': YayiCommonPython.scalar_type.s_ui32, 's_i64': YayiCommonPython.scalar_type.s_i64, 's_float': YayiCommonPython.scalar_type.s_float, 's_variant': YayiCommonPython.scalar_type.s_variant, 's_ui8': YayiCommonPython.scalar_type.s_ui8, 's_image': YayiCommonPython.scalar_type.s_image, 's_wstring': YayiCommonPython.scalar_type.s_wstring, 's_i8': YayiCommonPython.scalar_type.s_i8, 's_i32': YayiCommonPython.scalar_type.s_i32, 's_i16': YayiCommonPython.scalar_type.s_i16, 's_ui64': YayiCommonPython.scalar_type.s_ui64, 's_string': YayiCommonPython.scalar_type.s_string, 's_object': YayiCommonPython.scalar_type.s_object, 's_double': YayiCommonPython.scalar_type.s_double, 's_ui16': YayiCommonPython.scalar_type.s_ui16}
-
s_double = YayiCommonPython.scalar_type.s_double
-
s_float = YayiCommonPython.scalar_type.s_float
-
s_i16 = YayiCommonPython.scalar_type.s_i16
-
s_i32 = YayiCommonPython.scalar_type.s_i32
-
s_i64 = YayiCommonPython.scalar_type.s_i64
-
s_i8 = YayiCommonPython.scalar_type.s_i8
-
s_image = YayiCommonPython.scalar_type.s_image
-
s_object = YayiCommonPython.scalar_type.s_object
-
s_string = YayiCommonPython.scalar_type.s_string
-
s_ui16 = YayiCommonPython.scalar_type.s_ui16
-
s_ui32 = YayiCommonPython.scalar_type.s_ui32
-
s_ui64 = YayiCommonPython.scalar_type.s_ui64
-
s_ui8 = YayiCommonPython.scalar_type.s_ui8
-
s_variant = YayiCommonPython.scalar_type.s_variant
-
s_wstring = YayiCommonPython.scalar_type.s_wstring
-
values = {2: YayiCommonPython.scalar_type.s_ui8, 3: YayiCommonPython.scalar_type.s_ui16, 4: YayiCommonPython.scalar_type.s_ui32, 5: YayiCommonPython.scalar_type.s_ui64, 6: YayiCommonPython.scalar_type.s_i8, 7: YayiCommonPython.scalar_type.s_i16, 8: YayiCommonPython.scalar_type.s_i32, 9: YayiCommonPython.scalar_type.s_i64, 10: YayiCommonPython.scalar_type.s_float, 11: YayiCommonPython.scalar_type.s_double, 12: YayiCommonPython.scalar_type.s_object, 13: YayiCommonPython.scalar_type.s_variant, 14: YayiCommonPython.scalar_type.s_string, 15: YayiCommonPython.scalar_type.s_wstring, 16: YayiCommonPython.scalar_type.s_image}
-
class YayiCommonPython.type((object)arg1)
-
c_type
-
s_type