Ejemplo n.º 1
0
def update_colormap(attrname, old, new_frequency):
    """
    updates the coloring of the plot.
    :param attrname: unused, but needed for bokeh callback functions
    :param old: unused, but needed for bokeh callback functions
    :param new_frequency: new value for the frequency
    """
    mandel_iterations = source_mandel_raw.data['its'][0]

    frequency = int(
        np.mean(mandel_iterations[
                    mandel_iterations != int(slider_max_iterations.value)]) / new_frequency * 10)  # todo magic number?

    print "calculating colors."
    col = mandel_colormap.iteration_count_to_rgb_color(mandel_iterations, frequency, int(slider_max_iterations.value))
    img = mandel_colormap.rgb_color_to_bokeh_rgba(color=col)
    print "done."

    print "updating image data."
    view_data = my_bokeh_utils.get_user_view(plot)
    source_view.data = view_data
    source_image.data = dict(image=[img],
                             x0=view_data['x_start'],
                             y0=view_data['y_start'],
                             xw=[view_data['x_end'][0]-view_data['x_start'][0]],
                             yw=[view_data['y_end'][0]-view_data['y_start'][0]],
                             freq=[new_frequency])
    print "data was updated."
Ejemplo n.º 2
0
def update_colormap(attrname, old, new_frequency):
    """
    updates the coloring of the plot.
    :param attrname: unused, but needed for bokeh callback functions
    :param old: unused, but needed for bokeh callback functions
    :param new_frequency: new value for the frequency
    """
    mandel_iterations = source_mandel_raw.data['its'][0]

    frequency = int(
        np.mean(mandel_iterations[
            mandel_iterations != int(slider_max_iterations.value)]) /
        new_frequency * 10)  # todo magic number?

    print "calculating colors."
    col = mandel_colormap.iteration_count_to_rgb_color(
        mandel_iterations, frequency, int(slider_max_iterations.value))
    img = mandel_colormap.rgb_color_to_bokeh_rgba(color=col)
    print "done."

    print "updating image data."
    view_data = my_bokeh_utils.get_user_view(plot)
    source_view.data = view_data
    source_image.data = dict(
        image=[img],
        x0=view_data['x_start'],
        y0=view_data['y_start'],
        xw=[view_data['x_end'][0] - view_data['x_start'][0]],
        yw=[view_data['y_end'][0] - view_data['y_start'][0]],
        freq=[new_frequency])
    print "data was updated."
Ejemplo n.º 3
0
max_iterations = 10000
iteration_bound = 100
median_filtering_size = 0
gauss_filtering_sigma = 0.1

x0 = cx-d*.5
y0 = cy-d*.5
xw = d
yw = d

### main process starts here. ###

# calculate mandelbrot set
it_count = mandel.mandel(x0, y0, xw, yw, x_res, y_res, max_iterations, iteration_bound)

# apply some filters
if median_filtering_size is not 0:
    it_count = median_filter(it_count, size=median_filtering_size)
if gauss_filtering_sigma is not 0:
    it_count = gaussian_filter(it_count, sigma=gauss_filtering_sigma)

color = mandel_colormap.iteration_count_to_rgb_color(it_count, frequency, max_iterations)
print color.shape

# plot and save picture
img = smp.toimage(color) # Create a PIL image
img.save(name)
img.show()


max_iterations = 10000
iteration_bound = 100
median_filtering_size = 0
gauss_filtering_sigma = 0.1

x0 = cx - d * .5
y0 = cy - d * .5
xw = d
yw = d

### main process starts here. ###

# calculate mandelbrot set
it_count = mandel.mandel(x0, y0, xw, yw, x_res, y_res, max_iterations,
                         iteration_bound)

# apply some filters
if median_filtering_size is not 0:
    it_count = median_filter(it_count, size=median_filtering_size)
if gauss_filtering_sigma is not 0:
    it_count = gaussian_filter(it_count, sigma=gauss_filtering_sigma)

color = mandel_colormap.iteration_count_to_rgb_color(it_count, frequency,
                                                     max_iterations)
#print(color.shape)

# plot and save picture
img = smp.toimage(color)  # Create a PIL image
img.save(name)
img.show()