Example #1
0
def iso(image):
    # this should be placed at the top with all the imports
    from pyradar.classifiers.isodata import isodata_classification
    from pyradar.core.equalizers import equalization_using_histogram
    from pyradar.core.sar import save_image
    params = {"K": 15, "I": 100, "P": 2, "THETA_M": 10, "THETA_S": 0.1,
              "THETA_C": 2, "THETA_O": 0.01}

    # run Isodata
    class_image = isodata_classification(image, parameters=params)
    # equalize class image to 0:255
    class_image_eq = equalization_using_histogram(class_image)
    show_image(class_image_eq, 'isodata_classification')
Example #2
0
def iso(image):
    # this should be placed at the top with all the imports
    from pyradar.classifiers.isodata import isodata_classification
    from pyradar.core.equalizers import equalization_using_histogram
    from pyradar.core.sar import save_image
    params = {
        "K": 15,
        "I": 100,
        "P": 2,
        "THETA_M": 10,
        "THETA_S": 0.1,
        "THETA_C": 2,
        "THETA_O": 0.01
    }

    # run Isodata
    class_image = isodata_classification(image, parameters=params)
    # equalize class image to 0:255
    class_image_eq = equalization_using_histogram(class_image)
    show_image(class_image_eq, 'isodata_classification')
Example #3
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"
Example #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# this should be placed at the top with all the imports
from pyradar.classifiers.isodata import isodata_classification

params = {
    "K": 15,
    "I": 100,
    "P": 2,
    "THETA_M": 10,
    "THETA_S": 0.1,
    "THETA_C": 2,
    "THETA_O": 0.01
}

# run Isodata
class_image = isodata_classification(img, parameters=params)

# equalize class image to 0:255
class_image_eq = equalization_using_histogram(class_image)
# save it
save_image(IMG_DEST_DIR, "class_image_eq", class_image_eq)
# also save original image
image_eq = equalization_using_histogram(image)
# save it
save_image(IMG_DEST_DIR, "image_eq", image_eq)
Example #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"
Example #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# this should be placed at the top with all the imports
from pyradar.classifiers.isodata import isodata_classification

params = {"K": 15, "I" : 100, "P" : 2, "THETA_M" : 10, "THETA_S" : 0.1,
          "THETA_C" : 2, "THETA_O" : 0.01}

# run Isodata
class_image = isodata_classification(img, parameters=params)

# equalize class image to 0:255
class_image_eq = equalization_using_histogram(class_image)
# save it
save_image(IMG_DEST_DIR, "class_image_eq", class_image_eq)
# also save original image
image_eq = equalization_using_histogram(image)
# save it
save_image(IMG_DEST_DIR, "image_eq", image_eq)
params = {
    "K": 10,
    "I": 100,
    "P": 0,
    "THETA_M": 1,
    "THETA_S": 0.1,
    "THETA_C": 2,
    "THETA_O": 0.01
}

IMAGE_PATH = "/home/rccc/Downloads/LC81360272014242LGN00_B1.TIF"
IMG_DEST_DIR = "/home/rccc/Downloads/"
# create dataset
#dataset = create_dataset_from_path(IMAGE_PATH)

dataset = misc.imread(IMAGE_PATH)

# run Isodata
class_image = isodata_classification(dataset, parameters=params)

# equalize class image to 0:255
class_image_eq = equalization_using_histogram(class_image)

# save it
save_image(IMG_DEST_DIR, "class_image_eq", class_image_eq)
# also save original image
image_eq = equalization_using_histogram(dataset)

# save it
save_image(IMG_DEST_DIR, "image_eq", image_eq)