コード例 #1
0
 def templateDynamicLengthFastLinking(num_osc, steps, type_conn, repr_type,
                                      stimulus, ccore):
     params = pcnn_parameters()
     params.FAST_LINKING = True
     return PcnnTestTemplates.templateDynamicLength(num_osc,
                                                    steps,
                                                    type_conn,
                                                    repr_type,
                                                    stimulus,
                                                    ccore,
                                                    params=params)
コード例 #2
0
def template_segmentation_image(image, parameters, simulation_time, brightness, scale_color = True, fastlinking = False, show_spikes = False, ccore_flag = True):
    image_source = Image.open(image);
    image_size = image_source.size;
    
    width = image_size[0];
    height = image_size[1];
    
    stimulus = read_image(image);
    stimulus = rgb2gray(stimulus);
    
    if (brightness != None):
        for pixel_index in range(len(stimulus)):
            if (stimulus[pixel_index] < brightness): stimulus[pixel_index] = 1;
            else: stimulus[pixel_index] = 0;
    else:
        maximum_stimulus = float(max(stimulus));
        minimum_stimulus = float(min(stimulus));
        delta = maximum_stimulus - minimum_stimulus;
        
        for pixel_index in range(len(stimulus)):
            if (scale_color is True):
                stimulus[pixel_index] = 1.0 - ((float(stimulus[pixel_index]) - minimum_stimulus) / delta);
            else:
                stimulus[pixel_index] = float(stimulus[pixel_index]) / 255;
    
    if (parameters is None):
        parameters = pcnn_parameters();
    
        parameters.AF = 0.1;
        parameters.AL = 0.1;
        parameters.AT = 0.8;
        parameters.VF = 1.0;
        parameters.VL = 1.0;
        parameters.VT = 30.0;
        parameters.W = 1.0;
        parameters.M = 1.0;
        
        parameters.FAST_LINKING = fastlinking;
    
    net = pcnn_network(len(stimulus), parameters, conn_type.GRID_EIGHT, height = height, width = width, ccore = ccore_flag);
    output_dynamic = net.simulate(simulation_time, stimulus);
    
    pcnn_visualizer.show_output_dynamic(output_dynamic);
    
    ensembles = output_dynamic.allocate_sync_ensembles();
    draw_image_mask_segments(image, ensembles);
    
    pcnn_visualizer.show_time_signal(output_dynamic);
    
    if (show_spikes is True):
        spikes = output_dynamic.allocate_spike_ensembles();
        draw_image_mask_segments(image, spikes);
        
        pcnn_visualizer.animate_spike_ensembles(output_dynamic, image_size);
コード例 #3
0
def template_segmentation_image(image, parameters, simulation_time, brightness, scale_color = True, fastlinking = False, show_spikes = False, ccore_flag = True):
    image_source = Image.open(image);
    image_size = image_source.size;
    
    width = image_size[0];
    height = image_size[1];
    
    stimulus = read_image(image);
    stimulus = rgb2gray(stimulus);
    
    if (brightness != None):
        for pixel_index in range(len(stimulus)):
            if (stimulus[pixel_index] < brightness): stimulus[pixel_index] = 1;
            else: stimulus[pixel_index] = 0;
    else:
        maximum_stimulus = float(max(stimulus));
        minimum_stimulus = float(min(stimulus));
        delta = maximum_stimulus - minimum_stimulus;
        
        for pixel_index in range(len(stimulus)):
            if (scale_color is True):
                stimulus[pixel_index] = 1.0 - ((float(stimulus[pixel_index]) - minimum_stimulus) / delta);
            else:
                stimulus[pixel_index] = float(stimulus[pixel_index]) / 255;
    
    if (parameters is None):
        parameters = pcnn_parameters();
    
        parameters.AF = 0.1;
        parameters.AL = 0.1;
        parameters.AT = 0.8;
        parameters.VF = 1.0;
        parameters.VL = 1.0;
        parameters.VT = 30.0;
        parameters.W = 1.0;
        parameters.M = 1.0;
        
        parameters.FAST_LINKING = fastlinking;
    
    net = pcnn_network(len(stimulus), parameters, conn_type.GRID_EIGHT, height = height, width = width, ccore = ccore_flag);
    output_dynamic = net.simulate(simulation_time, stimulus);
    
    pcnn_visualizer.show_output_dynamic(output_dynamic);
    
    ensembles = output_dynamic.allocate_sync_ensembles();
    draw_image_mask_segments(image, ensembles);
    
    pcnn_visualizer.show_time_signal(output_dynamic);
    
    if (show_spikes is True):
        spikes = output_dynamic.allocate_spike_ensembles();
        draw_image_mask_segments(image, spikes);
        
        pcnn_visualizer.animate_spike_ensembles(output_dynamic, image_size);
コード例 #4
0
def segmentation_fast_linking_field_flowers():
    parameters = pcnn_parameters();

    parameters.AF = 0.1;
    parameters.AL = 0.1;
    parameters.AT = 0.8;
    parameters.VF = 1.0;
    parameters.VL = 1.0;
    parameters.VT = 80.0;
    parameters.W = 1.0;
    parameters.M = 1.0;
    
    parameters.FAST_LINKING = True;
    
    template_segmentation_image(IMAGE_REAL_SAMPLES.IMAGE_FIELD_FLOWER, parameters, 80, None, False, True, True); 
コード例 #5
0
def twenty_five_neurons_mix_stimulated():
    "Object allocation"
    "If M = 0 then only object will be allocated"
    params = pcnn_parameters()

    params.AF = 0.1
    params.AL = 0.0
    params.AT = 0.7
    params.VF = 1.0
    params.VL = 1.0
    params.VT = 10.0
    params.M = 0.0

    template_dynamic_pcnn(25, 100, [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
        0
    ], params, conn_type.GRID_FOUR, False)
コード例 #6
0
ファイル: pcnn_examples.py プロジェクト: Gudui/pyclustering
def twenty_five_neurons_mix_stimulated():
    "Object allocation"
    "If M = 0 then only object will be allocated"
    params = pcnn_parameters();
    
    params.AF = 0.1;
    params.AL = 0.0;
    params.AT = 0.7;
    params.VF = 1.0;
    params.VL = 1.0;
    params.VT = 10.0;
    params.M = 0.0;
    
    template_dynamic_pcnn(25, 100, [0, 0, 0, 0, 0, 
                                    0, 0, 0, 0, 0,
                                    0, 1, 1, 0, 0,
                                    0, 1, 1, 0, 0,
                                    0, 0, 0, 0, 0], params, conn_type.GRID_FOUR, False);
コード例 #7
0
def hundred_neurons_mix_stimulated():
    "Allocate several clusters: the first contains borders (indexes of oscillators) and the second objects (indexes of oscillators)"
    params = pcnn_parameters()

    params.AF = 0.1
    params.AL = 0.1
    params.AT = 0.8
    params.VF = 1.0
    params.VL = 1.0
    params.VT = 20.0
    params.W = 1.0
    params.M = 1.0

    template_dynamic_pcnn(100, 50, [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
        0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
        0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0
    ], params, conn_type.GRID_EIGHT, False)
コード例 #8
0
def segmentation_double_t():
    image = read_image(IMAGE_SIMPLE_SAMPLES.IMAGE_SIMPLE10);
    image = rgb2gray(image);

    for pixel_index in range(len(image)):
        if (image[pixel_index] < 128):
            image[pixel_index] = 1;
        else:
            image[pixel_index] = 0;

    params = pcnn_parameters();
    
    params.AF = 0.1;
    params.AL = 0.1;
    params.AT = 0.8;
    params.VF = 1.0;
    params.VL = 1.0;
    params.VT = 20.0;
    params.W = 1.0;
    params.M = 1.0;
    
    ensembles = template_dynamic_pcnn(32 * 32, 28,  image, params, conn_type.GRID_EIGHT, False);
    draw_image_mask_segments(IMAGE_SIMPLE_SAMPLES.IMAGE_SIMPLE10, ensembles);
コード例 #9
0
ファイル: pcnn_examples.py プロジェクト: Gudui/pyclustering
def hundred_neurons_mix_stimulated():
    "Allocate several clusters: the first contains borders (indexes of oscillators) and the second objects (indexes of oscillators)"
    params = pcnn_parameters();
    
    params.AF = 0.1;
    params.AL = 0.1;
    params.AT = 0.8;
    params.VF = 1.0;
    params.VL = 1.0;
    params.VT = 20.0;
    params.W = 1.0;
    params.M = 1.0;
    
    template_dynamic_pcnn(100, 50,  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                     0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
                                     0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
                                     0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                     0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
                                     0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
                                     0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0], params, conn_type.GRID_EIGHT, False);
コード例 #10
0
ファイル: pcnn_examples.py プロジェクト: Gudui/pyclustering
def segmentation_double_t():
    image = read_image(IMAGE_SIMPLE_SAMPLES.IMAGE_SIMPLE10);
    image = rgb2gray(image);

    for pixel_index in range(len(image)):
        if (image[pixel_index] < 128):
            image[pixel_index] = 1;
        else:
            image[pixel_index] = 0;

    params = pcnn_parameters();
    
    params.AF = 0.1;
    params.AL = 0.1;
    params.AT = 0.8;
    params.VF = 1.0;
    params.VL = 1.0;
    params.VT = 20.0;
    params.W = 1.0;
    params.M = 1.0;
    
    ensembles = template_dynamic_pcnn(32 * 32, 28,  image, params, conn_type.GRID_EIGHT, False);
    draw_image_mask_segments(IMAGE_SIMPLE_SAMPLES.IMAGE_SIMPLE10, ensembles);
コード例 #11
0
 def templateDynamicLengthFastLinking(num_osc, steps, type_conn, repr_type, stimulus, ccore):
     params = pcnn_parameters();
     params.FAST_LINKING = True;
     return PcnnTestTemplates.templateDynamicLength(num_osc, steps, type_conn, repr_type, stimulus, ccore, params=params);
コード例 #12
0
def nine_neurons_stimulated_one_sync():
    "Just dynamic demonstration"
    params = pcnn_parameters()
    template_dynamic_pcnn(9, 100, [1.0] * 9, params, conn_type.GRID_FOUR)
コード例 #13
0
def template_segmentation_image(image,
                                parameters,
                                simulation_time,
                                brightness,
                                scale_color=True,
                                fastlinking=False,
                                show_spikes=False,
                                ccore_flag=True):
    image_source = Image.open(image)
    image_size = image_source.size

    width = image_size[0]
    height = image_size[1]

    stimulus = read_image(image)
    stimulus = rgb2gray(stimulus)

    if brightness is not None:
        for pixel_index in range(len(stimulus)):
            if stimulus[pixel_index] < brightness:
                stimulus[pixel_index] = 1
            else:
                stimulus[pixel_index] = 0
    else:
        maximum_stimulus = float(max(stimulus))
        minimum_stimulus = float(min(stimulus))
        delta = maximum_stimulus - minimum_stimulus

        for pixel_index in range(len(stimulus)):
            if scale_color is True:
                stimulus[pixel_index] = 1.0 - (
                    (float(stimulus[pixel_index]) - minimum_stimulus) / delta)
            else:
                stimulus[pixel_index] = float(stimulus[pixel_index]) / 255

    if parameters is None:
        parameters = pcnn_parameters()

        parameters.AF = 0.1
        parameters.AL = 0.1
        parameters.AT = 0.8
        parameters.VF = 1.0
        parameters.VL = 1.0
        parameters.VT = 30.0
        parameters.W = 1.0
        parameters.M = 1.0

        parameters.FAST_LINKING = fastlinking

    net = pcnn_network(len(stimulus),
                       parameters,
                       conn_type.GRID_EIGHT,
                       height=height,
                       width=width,
                       ccore=ccore_flag)
    output_dynamic = net.simulate(simulation_time, stimulus)

    pcnn_visualizer.show_output_dynamic(output_dynamic)

    ensembles = output_dynamic.allocate_sync_ensembles()
    draw_image_mask_segments(image, ensembles)

    pcnn_visualizer.show_time_signal(output_dynamic)

    if show_spikes is True:
        spikes = output_dynamic.allocate_spike_ensembles()
        draw_image_mask_segments(image, spikes)

        pcnn_visualizer.animate_spike_ensembles(output_dynamic, image_size)
コード例 #14
0
ファイル: pcnn_examples.py プロジェクト: Gudui/pyclustering
def nine_neurons_stimulated_one_sync():
    "Just dynamic demonstration"
    params = pcnn_parameters();
    template_dynamic_pcnn(9, 100, [1.0] * 9, params, conn_type.GRID_FOUR);