Beispiel #1
0
def radon_transform(image=None):
    #if image == None:
    image = imread("kolo.jpg", as_grey=True)

    #image = imread(data_dir + "/phantom.png")#
    #image = np.zeros([501,501,3])
    #image = image/255

    radon = Radon(image, DETECTORS_NR, ANGULAR_SPREAD, ITERATION_ANGLE,
                  FILTER_SIZE)
    radon.transform()
    image = radon.getSinogram()
    image = radon.normalize(image)
    #cir = Circle(DETECTORS_NR, ANGULAR_SPREAD, ITERATION_ANGLE)
    #print(cir.getPoint(0))

    fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
    ax.imshow(image, aspect='auto', cmap='gray')
    plt.show()

    radon.transform(inverse=True)
    image = radon.getResult()
    image = radon.normalize(image)

    fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
    ax.imshow(image, aspect='auto', cmap='gray')
    plt.show()
def plot2():
    det_nr = 251
    ang_spr = 90
    it_ang = 2
    flt_size = 0
    image = imread("pic_s.png", as_grey=True)
    x = []
    y = []
    for var in range(0, 50, 5):
        imageCopy = np.copy(image)
        radon = Radon(image, det_nr, ang_spr, it_ang, var)
        radon.transform()
        radon.transform(inverse=True)
        sig = radon.getSinogram()
        sig = radon.normalize(sig)
        # fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
        # ax.imshow(sig, aspect='auto', cmap='gray')
        # plt.savefig("filtr{}sig.pdf".format(var))
        res = radon.getResult()
        res = radon.normalize(res)
        fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
        # ax.imshow(res, aspect='auto', cmap='gray')
        # plt.savefig("filtr{}.pdf".format(var))
        err = MeanSquaredError(imageCopy, res)
        x.append(var)
        y.append(err)
        print("var = {}".format(var * 2 + 1 if var else var))
    fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
    ax.plot(x, y)
    ax.set_xlabel("Filter size")
    ax.set_ylabel("Root Mean Squared Error")
    ax.set_xticks(x)
    plt.show()
def plot3():
    det_nr = 51
    ang_spr = 90
    it_ang = 2
    flt_size = 0
    image = imread("pic_s.png", as_grey=True)
    x = []
    y = []
    for var in range(1, 180, 5):
        imageCopy = np.copy(image)
        radon = Radon(image, det_nr, ang_spr, var, flt_size)
        radon.transform()
        radon.transform(inverse=True)
        res = radon.getResult()
        res = radon.normalize(res)
        err = MeanSquaredError(imageCopy, res)
        x.append(var)
        y.append(err)
        print("var = {}".format(var))
    fig, ax = plt.subplots(sharex=True, figsize=(5, 5))
    ax.plot(x, y)
    ax.set_xlabel("Iteration angle")
    ax.set_ylabel("Root Mean Squared Error")
    ax.set_xticks(x)
    plt.show()
Beispiel #4
0
def radon_transform(image = None):
    #if image == None:
    image = imread("pic_s.png", as_grey=True)

    #image = imread(data_dir + "/phantom.png")#
    #image = np.zeros([501,501,3])
    #image = image/255

    radon = Radon(image, DETECTORS_NR, ANGULAR_SPREAD, ITERATION_ANGLE)
    radon.transform()
    radon.inverse()
    image=radon.getSinogram()
    print(image.shape, math.ceil(360/ITERATION_ANGLE))