Images

This module currently supports implementing the wave graph architecture for processing image data

Image grid graph API

class tflon.image.graph.ImageGraph2D(graph)

Issue: i wrote all of these assuming the actual image itself was going to be passed into Graph, and so I thought I needed to return blocks full of actual image pixel values…

1. Do these things being initialized need to be something different? as it is, it seems we are generating a bunch of data for little reason, and there are likely other things to modify to make it faster. Yes. he says make them generators. Perhaps do that later. 2. Question: how the heck could we do neighbors if we didn’t know the number node id to expect in each position?

Now graph will be a tuple, (hight,width)

bfs(c_coords)

This returns blocks and ancestors given an image. Blocks is a list of lists containing the nodes (pixels) in each shell. Ancestors is the dicitonary with each pixel as keys, and as values a list (automatically sorted) of the immediate predecessors.

For the four if statements below:
This obtains all the ancestors. Those in the same row or column as the starting will have only one ancestor. This new ordering will spit out with the ancestor lists sorted by position in the array.
centroids()

returns center pixel in image graph. Inputs: self._graph should be an image, not an nx.graph object outputs: the center pixel’s value as a vector (of dimension 512 if using the VGG) Note that it will return the center pixel for odd-dimensions, and the left/top of center pair for even dimensions. For a line of 4 pixels, that means it picks the second pixel, having python index 1.

get_edges_init()

Should still be improved

get_node_id(i, j)

Returns the node number, which is rastor scan style

neighborhood(node, max_depth=9223372036854775807)

Just passing in the node number to start on. It’s used by pool_featurize. Note: I’m assuming the node will be a # in a grid graph, starting at 1 raster scan style [[1,2,3],[4,5,6],[7,8,9]] Note: This should potentially be changed to be 0-indexed

tflon.image.graph.block_preorder(ancestors)

returns nodes as list of lists in the layer order they are visited in the bfs [[n0],[n1,n2],[n3]] It does this becuase for a node to go into empty and get appended to blocks, it must not have been put into blocks and visited yet, but all of its ancestors must have been put into blocks and visited. Thus it can only work outward one layer at a time, and all those unvisited with all ancestors visited will be in the same layer.

tflon.image.graph.flip_ancestors(D)

This reverses the order of all the graph connections, putting the descendents as the ancestors in a new dictionary It does this by adding the former keys as values for the new keys that are the old values. So it reverses the traversal order of every edge.

Input: ancestors: dict with history one back so now like {n0:{}, n1:{n0}, n2:{n0}, n3:{n1,n2}} Output: {n0:{n1,n2},n1:{n3},n2:{n3}}

class tflon.image.graph.type_overwrite(edge)