Beispiel #1
0
def test_mask_neighbors_3d(allnbrs=True):
    from pyimgalgos.NDArrGenerators import random_exponential
    import pyimgalgos.Graphics as gr

    #randexp = random_exponential(shape=(2,2,30,80), a0=1)
    randexp = random_exponential(shape=(2, 30, 80), a0=1)

    fig = gr.figure(figsize=(16, 6), title='Random > 2-d mask')
    axim1 = gr.add_axes(fig, axwin=(0.05, 0.05, 0.40, 0.91))
    axcb1 = gr.add_axes(fig, axwin=(0.452, 0.05, 0.01, 0.91))

    axim2 = gr.add_axes(fig, axwin=(0.55, 0.05, 0.40, 0.91))
    axcb2 = gr.add_axes(fig, axwin=(0.952, 0.05, 0.01, 0.91))

    mask = np.select((randexp > 6, ), (0, ), default=1)
    mask_nbrs = mask_neighbors(mask, allnbrs)

    img1 = reshape_nda_to_2d(mask)
    img2 = reshape_nda_to_2d(mask_nbrs)

    imsh1, cbar1 = gr.imshow_cbar(fig,
                                  axim1,
                                  axcb1,
                                  img1,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    imsh2, cbar2 = gr.imshow_cbar(fig,
                                  axim2,
                                  axcb2,
                                  img2,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    gr.show(mode=None)
Beispiel #2
0
def test_mask_edges_2d(mrows=1, mcols=1):
    from pyimgalgos.NDArrGenerators import random_exponential
    import pyimgalgos.Graphics as gr

    fig = gr.figure(figsize=(8, 6), title='Mask edges 2-d')
    axim1 = gr.add_axes(fig, axwin=(0.05, 0.05, 0.87, 0.91))
    axcb1 = gr.add_axes(fig, axwin=(0.922, 0.05, 0.01, 0.91))

    mask = np.ones((20, 30))
    mask_out = mask_edges(mask, mrows, mcols)

    img1 = mask_out
    imsh1, cbar1 = gr.imshow_cbar(fig,
                                  axim1,
                                  axcb1,
                                  img1,
                                  amin=0,
                                  amax=10,
                                  orientation='vertical')
    gr.show(mode=None)