예제 #1
0
def plotmask(maskwoutput=None, maxr=None, xray_image=None,
             position_matrix=None):
    """
    Plots the mask metrics allowing for evaluation of mask quality
    """

    # highper,lowper,totalper, mask, imask,StatsA=maskwoutput
    highper, lowper, totalper, mask, imask = maskwoutput
    # May need matplotlib help from Tom on this
    plt.ioff()
    plt.clf()
    # plot the graph of how the mask depends on radial distance
    # TODO: use Q instead of r in the final product?
    plt.plot(np.arange(0, maxr + 1, 1), highper[:], '-',
             np.arange(0, maxr + 1, 1), lowper[:], 'o',
             np.arange(0, maxr + 1, 1), totalper[:], '^')
    plt.show()
    # Plot the mask itself
    # plot the overlay of the mask and the image
    mask = plt.imshow(mask)
    plt.show()
    imagemask = plt.imshow(xray_image * imask)
    plt.show()
    t = np.arange(0, maxr, 1)
    plt.plot(t, Calculate.mean1d(xray_image,
                                 position_matrix=position_matrix * imask,
                                 step=1), 'b',
             # t, Median1D(xray_image, max=maxr, step=1, position_matrix=position_matrix*imask), 'r',\
             # t,Median1D(xray_image, max=maxr, step=1, position_matrix=position_matrix*imask)-Mean1D(xray_image, max=maxr, step=1, position_matrix=position_matrix*imask)
    )
    plt.show()

    oldstd = np.sqrt(
        Calculate.variance1d(xray_image, position_matrix=position_matrix,
                             max=maxr, step=1))
    newstd = np.sqrt(Calculate.variance1d(xray_image,
                                          position_matrix=position_matrix * imask,
                                          max=maxr, step=1))
    plt.plot(t, oldstd, 'b', t, newstd, 'r', t, oldstd - newstd, 'g')
    plt.show()