def trisect_image(imshape, edgepts='<STR_LIT>'):
im_x, im_y = np.meshgrid(np.arange(imshape[<NUM_LIT:0>]), np.arange(imshape[<NUM_LIT:1>]),<EOL>indexing='<STR_LIT>')<EOL>if np.size(edgepts) == <NUM_LIT:1>:<EOL><INDENT>f = np.sqrt(<NUM_LIT>/<NUM_LIT>) if edgepts == '<STR_LIT>' else edgepts<EOL>lower_edge = (imshape[<NUM_LIT:0>] * (<NUM_LIT:1>-f),  imshape[<NUM_LIT:1>] * f)<EOL>upper_edge = (imshape[<NUM_LIT:0>] * f,      imshape[<NUM_LIT:1>] * (<NUM_LIT:1>-f))<EOL><DEDENT>else:<EOL><INDENT>upper_edge, lower_edge = edgepts<EOL><DEDENT>lower_slope = lower_edge[<NUM_LIT:1>] / max(float(imshape[<NUM_LIT:0>] - lower_edge[<NUM_LIT:0>]), <NUM_LIT>)<EOL>upper_slope = (imshape[<NUM_LIT:1>] - upper_edge[<NUM_LIT:1>]) / float(upper_edge[<NUM_LIT:0>])<EOL>lower_intercept = -lower_slope * lower_edge[<NUM_LIT:0>]<EOL>upper_intercept = upper_edge[<NUM_LIT:1>]<EOL>lower_mask = im_y < (im_x * lower_slope + lower_intercept)<EOL>upper_mask = im_y > (im_x * upper_slope + upper_intercept)<EOL>center_mask= -(lower_mask | upper_mask)<EOL>return upper_mask, center_mask, lower_mask<EOL>
Returns 3 masks that trisect an image into 3 triangular portions.

Parameters
----------
    imshape : 2-element list-like of ints
        The shape of the image. Elements after the first 2 are ignored.

    edgepts : Nested list-like, float, or `calc`, optional.
        The vertices of the triangles which determine the splitting of
        the image. The vertices are at (image corner, (edge, y), and
        (x,edge), where edge is the appropriate edge of the image.
            edgepts[0] : (x,y) points for the upper edge
            edgepts[1] : (x,y) points for the lower edge
        where `x` is the coordinate along the image's 0th axis and `y`
        along the images 1st axis. Default is 'calc,' which calculates
        edge points by splitting the image into 3 regions of equal
        area. If edgepts is a float scalar, calculates the edge points
        based on a constant fraction of distance from the edge.

Returns
-------
    upper_mask : numpy.ndarray
        Boolean array; True in the image's upper  region.
    center_mask : numpy.ndarray
        Boolean array; True in the image's center region.
    lower_mask : numpy.ndarray
        Boolean array; True in the image's lower  region.