pyaesthetics.quadtreedecomposition.quadTree

class pyaesthetics.quadtreedecomposition.quadTree(img, minStd, minSize, autoadjust=False)

Bases: object

This class performs a QuadTree decomposition of an image.

During initialization, the QuadTree decomposition is done and results are stored in self.blocks as a list containing [x, y, height, width, Std]. To visualize the results, use the plot() method. The total number of blocks is stored in self.nblocks, while the standardized complexity (number of blocks divided by the total possible number of blocks is stored in self.standardized_complexity. Standardized complexity may range from 0 to 1 (with one being the highest complexity possible). The minSize parameter can be automatically adjusted to the common divisor of image width and height closest to the inputted minSize via the autoadjust parameter (default to False). The adjusted minSize can be obtained (if autoadjust = True) by accessing self.minSize.

Initialize the QuadTree decomposition analysis.

Parameters:
  • img (numpy.ndarray) – Image to analyze

  • minStd (int) – Standard deviation threshold for subsequent splitting

  • minSize (int) – Size threshold for subsequent splitting, in pixels

Methods

max_quadtree_leaves

Calculate the maximum number of leaves in a quadtree decomposition of an image.

plot

Generate a graphical representation of the QuadTree decomposition.

quad_tree_decomposition

Evaluate the mean and standard deviation of an image block, and decide whether to perform further splits of the block.

max_quadtree_leaves(width, height, min_leaf_size)

Calculate the maximum number of leaves in a quadtree decomposition of an image.

Parameters:
  • width (int) – Width of the image in pixels.

  • height (int) – Height of the image in pixels.

  • min_leaf_size (int) – Minimum size of each side of a leaf in pixels.

Returns:

Maximum number of leaves in the quadtree decomposition.

Return type:

int

plot(edgecolor='red', facecolor='none', linewidth=1)

Generate a graphical representation of the QuadTree decomposition.

Parameters:
  • edgecolor (string) – Color of the rectangle edges, default is red

  • facecolor (string) – Color used for rectangle fills. Default is none.

  • linewidth (int) – Width of the rectangles’ borders in pixels. Default is 1.

Returns:

Plot with image and leaves of the QuadTree Decomposition

quad_tree_decomposition(img, x, y, minStd, minSize)

Evaluate the mean and standard deviation of an image block, and decide whether to perform further splits of the block.

Parameters:
  • img (numpy.ndarray) – Image to analyze

  • x (int) – X offset of the block to analyze

  • y (int) – Y offset of the block to analyze

  • minStd (int) – Standard deviation threshold for subsequent splitting

  • minSize (int) – Size threshold for subsequent splitting, in pixels