Пример #1
0
def get_circle(size):
    circle = np.zeros((size, size))
    radius = size // 2
    center = (radius, radius)
    for y in range(0, size):
        for x in range(0, size):
            if (x - radius)**2 + (y - radius)**2 < radius**2:
                circle[y, x] = 1
    for i in np.arange(0, 360, .1):
        x, y = calculatePositionSafe(i, size, center)
        circle[y, x] = 1
    return circle
Пример #2
0
def radon(oryg_image, image, angle, n_detectors, sinogram_arr, emission_angle, diameter):
    angle_between_rays = emission_angle / (n_detectors - 1)
    angles = np.arange(-emission_angle/2, emission_angle/2 + emission_angle/n_detectors , angle_between_rays)

    radius = diameter // 2 - 1
    center = (radius, radius)
    start = calculatePositionSafe(angle, diameter, center)
    x = 0
    for i in angles:
        if parallel_rays_mode:
            start, end = parallel_ray(start, angle, i*2, diameter, center)
        else:
            end = inclined_ray(angle, i*2, diameter, center)
        line_sum = draw_line(oryg_image, image, start_point=start, end_point=end)
        sinogram_arr[angle, x] = line_sum
        x += 1
Пример #3
0
def inverse_radon(image, sinogram, diameter, angle, emission_angle, n_detectors):
    angle_between_rays = emission_angle / (n_detectors - 1)
    angles = np.arange(-emission_angle / 2, emission_angle / 2 + emission_angle / n_detectors, angle_between_rays)

    radius = diameter // 2 - 1
    center = (radius, radius)
    start = calculatePositionSafe(angle, diameter, center)

    x = 0
    for i in angles:
        if parallel_rays_mode:
            start, end = parallel_ray(start, angle, i*2, diameter, center)
        else:
            end = inclined_ray(angle, i*2, diameter, center)
        reconstruct_line(sinogram_value=sinogram[angle, x], reconstruction_image=image, start_point=start, end_point=end)
        x+=1
Пример #4
0
def inclined_ray(main_angle, minor_angle, diameter, center):
    end_point = calculatePositionSafe(main_angle + minor_angle, diameter,
                                      center)
    return (diameter - end_point[0], diameter - end_point[1])
Пример #5
0
def parallel_ray(main_point_start, main_angle, minor_angle, diameter, center):
    start = calculatePositionSafe(main_angle + minor_angle, diameter, center)
    end = calculatePositionSafe(main_angle - 180 + (-1) * minor_angle,
                                diameter, center)
    return start, end