# -*- coding: utf-8 -*-
from pyradar.simulate.image_simulator import ImageSimulator
from pyradar.utils.timeutils import Timer
pylab.close()

timer = Timer()
width, height = 2000, 2000

gamma_ims = ImageSimulator(width, height)
k_ims = ImageSimulator(width, height)
noise_layer_ims = ImageSimulator(width, height)

gamma_params = {'scale': 2.0, 'shape': 3.0}
k_params = {'mean': 2.0, 'shape': 2.0}
noise_layer_params = {'df': 3}

gamma_ims.generate_image_layer(distribution='gamma', params=gamma_params)
k_ims.generate_image_layer(distribution='k', params=k_params)
noise_layer_ims.generate_noise_layer(distribution='chisquare', params=noise_layer_params)

# Make some noise!
gamma_ims.noise_layer = noise_layer_ims.noise_layer
k_ims.noise_layer = noise_layer_ims.noise_layer
gamma_ims.generate_noisy_layer()
k_ims.generate_noisy_layer()

timer.calculate_time_elapsed(print_value=True)
# Export the files:
gamma_ims.export_image_layer(layer_name='image_layer', filename='gamma_img_layer',
                             path_to='.')
k_ims.export_image_layer(layer_name='image_layer', filename='k_img_layer',
Exemple #2
0
    def test_all(self):
        image_path = os.path.join(IMAGES,  "DAT_01.001")

        print image_path

        dataset = create_dataset_from_path(image_path)
        band = get_band_from_dataset(dataset)

        geoinfo = get_geoinfo(dataset, cast_to_int=True)

        xoff = geoinfo['xoff'] + 2000
        yoff = geoinfo['yoff'] + 2000

        ## Parameters:
        win_xsize = 100  # window size in coord x
        win_ysize = 100  # window size in coord y
        k = 1  # parameter of frost filter, ex: k=1 or k=10 or k=100
        win_size = 3  # size of the window for the filter function
        damping_factor = 1  # parameter of frost filter, ex: 1 or 10 or 1000

        image = read_image_from_band(band, xoff, yoff, win_xsize, win_ysize)

        # Try K-Means
        kmean_timer = Timer()
        n_classes = 8
        iterations = 1000
        class_image = kmeans_classification(image, n_classes, iterations)
        kmean_timer.stop_timer()
        kmean_timer.calculate_time_elapsed(print_value=True)

        # Try Isodata
        isodata_timer = Timer()
        parameters={"K": 8, "I":1000}
        class_image = isodata_classification(image,parameters=parameters )
        isodata_timer.stop_timer()
        isodata_timer.calculate_time_elapsed(print_value=True)
        numerito = parameters["K"]

        # Try the filters
        filter_timer = Timer()
        numerito = 11
        cucito = 0.30
        image_filtered = mean_filter(image, win_size=numerito)
        image_filtered = median_filter(image,win_size)
        image_filtered = frost_filter(image, damping_factor=1.0, win_size=11)
        image_filtered = kuan_filter(image, win_size=7, cu=1.0)
        image_filtered = lee_filter(image, win_size=numerito, cu=cucito)
        image_filtered = lee_enhanced_filter(image, win_size=numerito, cu=cucito)
        filter_timer.stop_timer()
        diff = filter_timer.calculate_time_elapsed(print_value=True)

        # Frost y K-Means
        ventana = 7
        damp = 1.0
    #
        parameters={"K" : 5, "I" : 100}
    #
        _timer = Timer()
    #
        image_filtered = frost_filter(image, damping_factor=damp, win_size=ventana)
        class_image = isodata_classification(image_filtered, parameters)
    #
    #
        _timer.stop_timer()
        _timer.calculate_time_elapsed(print_value=True)
    #
        image_corrected = equalization_using_histogram(class_image)
        save_image(IMG_DEST_DIR, "image_" + str(ventana) + "frostisodata" +
                    str(damp) + "c"  + str(parameters["K"]), image_corrected)
    #
    #

        # Equalize and save the images to files
        image_corrected = equalization_using_histogram(class_image)
        save_image(IMG_DEST_DIR, "image_isodata8", image_corrected)
    #
        image_original = equalization_using_histogram(image)
        save_image(IMG_DEST_DIR, "image_original", image_original)

        print "\a\a\a"
Exemple #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyradar.simulate.image_simulator import ImageSimulator
from pyradar.utils.timeutils import Timer
import p
pylab.close()

timer = Timer()
width, height = 2000, 2000

gamma_ims = ImageSimulator(width, height)
k_ims = ImageSimulator(width, height)
noise_layer_ims = ImageSimulator(width, height)

gamma_params = {'scale': 2.0, 'shape': 3.0}
k_params = {'mean': 2.0, 'shape': 2.0}
noise_layer_params = {'df': 3}

gamma_ims.generate_image_layer(distribution='gamma', params=gamma_params)
k_ims.generate_image_layer(distribution='k', params=k_params)
noise_layer_ims.generate_noise_layer(distribution='chisquare',
                                     params=noise_layer_params)

# Make some noise!
gamma_ims.noise_layer = noise_layer_ims.noise_layer
k_ims.noise_layer = noise_layer_ims.noise_layer
gamma_ims.generate_noisy_layer()
k_ims.generate_noisy_layer()

timer.calculate_time_elapsed(print_value=True)
# -*- coding: utf-8 -*-
from pyradar.utils.timeutils import Timer

# crea y arranca el timer
simple_timer = Timer()
# procedimiento que queremos medir
result = function(arg1, arg2)
# paramos el timer
simple_timer.stop_timer()
#imprimimos los resultados y los guardamos en diff
diff = simple_timer.calculate_time_elapsed(print_value=True)

Exemple #5
0
    def test_all(self):
        image_path = os.path.join(IMAGES,  "DAT_01.001")

        print image_path

        dataset = create_dataset_from_path(image_path)
        band = get_band_from_dataset(dataset)

        geoinfo = get_geoinfo(dataset, cast_to_int=True)

        xoff = geoinfo['xoff'] + 2000
        yoff = geoinfo['yoff'] + 2000

        ## Parameters:
        win_xsize = 100  # window size in coord x
        win_ysize = 100  # window size in coord y
        k = 1  # parameter of frost filter, ex: k=1 or k=10 or k=100
        win_size = 3  # size of the window for the filter function
        damping_factor = 1  # parameter of frost filter, ex: 1 or 10 or 1000

        image = read_image_from_band(band, xoff, yoff, win_xsize, win_ysize)

        # Try K-Means
        kmean_timer = Timer()
        n_classes = 8
        iterations = 1000
        class_image = kmeans_classification(image, n_classes, iterations)
        kmean_timer.stop_timer()
        kmean_timer.calculate_time_elapsed(print_value=True)

        # Try Isodata
        isodata_timer = Timer()
        parameters={"K": 8, "I":1000}
        class_image = isodata_classification(image,parameters=parameters )
        isodata_timer.stop_timer()
        isodata_timer.calculate_time_elapsed(print_value=True)
        numerito = parameters["K"]

        # Try the filters
        filter_timer = Timer()
        numerito = 11
        cucito = 0.30
        image_filtered = mean_filter(image, win_size=numerito)
        image_filtered = median_filter(image,win_size)
        image_filtered = frost_filter(image, damping_factor=1.0, win_size=11)
        image_filtered = kuan_filter(image, win_size=7, cu=1.0)
        image_filtered = lee_filter(image, win_size=numerito, cu=cucito)
        image_filtered = lee_enhanced_filter(image, win_size=numerito, cu=cucito)
        filter_timer.stop_timer()
        diff = filter_timer.calculate_time_elapsed(print_value=True)

        # Frost y K-Means
        ventana = 7
        damp = 1.0
    #
        parameters={"K" : 5, "I" : 100}
    #
        _timer = Timer()
    #
        image_filtered = frost_filter(image, damping_factor=damp, win_size=ventana)
        class_image = isodata_classification(image_filtered, parameters)
    #
    #
        _timer.stop_timer()
        _timer.calculate_time_elapsed(print_value=True)
    #
        image_corrected = equalization_using_histogram(class_image)
        save_image(IMG_DEST_DIR, "image_" + str(ventana) + "frostisodata" +
                    str(damp) + "c"  + str(parameters["K"]), image_corrected)
    #
    #

        # Equalize and save the images to files
        image_corrected = equalization_using_histogram(class_image)
        save_image(IMG_DEST_DIR, "image_isodata8", image_corrected)
    #
        image_original = equalization_using_histogram(image)
        save_image(IMG_DEST_DIR, "image_original", image_original)

        print "\a\a\a"
Exemple #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyradar.utils.timeutils import Timer

# crea y arranca el timer
simple_timer = Timer()
# procedimiento que queremos medir
result = function(arg1, arg2)
# paramos el timer
simple_timer.stop_timer()
#imprimimos los resultados y los guardamos en diff
diff = simple_timer.calculate_time_elapsed(print_value=True)