Exemplo n.º 1
0
def filters_eq(image, use_acceleration=True):
    if not use_acceleration:
        from pyradar.filters.frost import frost_filter
        from pyradar.filters.kuan import kuan_filter
        from pyradar.filters.lee import lee_filter
        from pyradar.filters.lee_enhanced import lee_enhanced_filter
        from pyradar.filters.mean import mean_filter
    else:
        from pyradar.filters.accelerated.frost import frost_filter
        from pyradar.filters.accelerated.kuan import kuan_filter
        from pyradar.filters.accelerated.lee import lee_filter
        from pyradar.filters.accelerated.lee_enhanced import lee_enhanced_filter
        from pyradar.filters.accelerated.mean import mean_filter
    from pyradar.filters.median import median_filter
    # filters parameters

    winsize = 15  # window size
    k_value1 = 2.0  # damping factor for frost
    k_value2 = 1.0  # damping factor for lee enhanced
    cu_value = 0.25  # coefficient of variation of noise
    cu_lee_enhanced = 0.523  # coefficient of variation for lee enhanced of noise
    cmax_value = 1.73  # max coefficient of variation for lee enhanced

    # frost filter
    tic('Frost')
    image_frost = frost_filter(image,
                               damping_factor=k_value1,
                               win_size=winsize)
    toc()
    tic('Kuan')
    image_kuan = kuan_filter(image, win_size=winsize, cu=cu_value)
    toc()
    tic('Lee')
    image_lee = lee_filter(image, win_size=winsize, cu=cu_value)
    toc()
    tic('Lee_ench')
    image_lee_enhanced = lee_enhanced_filter(image,
                                             win_size=winsize,
                                             k=k_value2,
                                             cu=cu_lee_enhanced,
                                             cmax=cmax_value)

    toc()

    show_image([(image, 'original'), (image_frost, 'Frost'),
                (image_kuan, 'Kuan'), (image_lee, 'Lee'),
                (image_lee_enhanced, 'lee_e')])

    # kuan filter
    # tic('Kuan')
    # toc()
    # show_image([(image, 'original'), (image_kuan, 'Kuan') ])

    # exit()
    # # lee filter

    exit()
    # lee enhanced filter
    show_image(image_lee_enhanced, 'Enchanced Lee')
Exemplo n.º 2
0
def naive_eq(image):
    # get actual range
    input_range = image.min(), image.max()
    # set new range
    output_range = 0, 255
    # equalize image
    image_eq = naive_equalize_image(image, input_range, output_range)
    # save image in current directory
    show_image(image_eq, 'Naive equalization')
Exemplo n.º 3
0
def naive_eq(image):
    # get actual range
    input_range = image.min(), image.max()
    # set new range
    output_range = 0, 255
    # equalize image
    image_eq = naive_equalize_image(image, input_range, output_range)
    # save image in current directory
    show_image(image_eq, 'Naive equalization')
Exemplo n.º 4
0
def filters_eq(image, use_acceleration=True):
    if not use_acceleration:
        from pyradar.filters.frost import frost_filter
        from pyradar.filters.kuan import kuan_filter
        from pyradar.filters.lee import lee_filter
        from pyradar.filters.lee_enhanced import lee_enhanced_filter
        from pyradar.filters.mean import mean_filter
    else:
        from pyradar.filters.accelerated.frost import frost_filter
        from pyradar.filters.accelerated.kuan import kuan_filter
        from pyradar.filters.accelerated.lee import lee_filter
        from pyradar.filters.accelerated.lee_enhanced import lee_enhanced_filter
        from pyradar.filters.accelerated.mean import mean_filter
    from pyradar.filters.median import median_filter
    # filters parameters

    winsize = 15 # window size
    k_value1 = 2.0 # damping factor for frost
    k_value2 = 1.0 # damping factor for lee enhanced
    cu_value = 0.25 # coefficient of variation of noise
    cu_lee_enhanced = 0.523 # coefficient of variation for lee enhanced of noise
    cmax_value = 1.73 # max coefficient of variation for lee enhanced

    # frost filter
    tic('Frost')
    image_frost = frost_filter(image, damping_factor=k_value1, win_size=winsize)
    toc()
    tic('Kuan')
    image_kuan = kuan_filter(image, win_size=winsize, cu=cu_value)
    toc()
    tic('Lee')
    image_lee = lee_filter(image, win_size=winsize, cu=cu_value)
    toc()
    tic('Lee_ench')
    image_lee_enhanced = lee_enhanced_filter(image, win_size=winsize, k=k_value2,
                                             cu=cu_lee_enhanced, cmax=cmax_value)

    toc()

    show_image([(image, 'original'), (image_frost, 'Frost'), (image_kuan, 'Kuan'), (image_lee, 'Lee'),
                (image_lee_enhanced, 'lee_e')])

    # kuan filter
    # tic('Kuan')
    # toc()
    # show_image([(image, 'original'), (image_kuan, 'Kuan') ])

    # exit()
    # # lee filter

    exit()
    # lee enhanced filter
    show_image(image_lee_enhanced, 'Enchanced Lee')
Exemplo n.º 5
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')
Exemplo n.º 6
0
def kmeans(image):
    from pyradar.classifiers.kmeans import kmeans_classification
    # number of clusters
    k = 4
    # max number of iterations
    iter_max = 1000
    # run K-Means
    class_image = kmeans_classification(image, k, iter_max)

    # equalize class image to 0:255
    class_image_eq = equalization_using_histogram(class_image)
    # save it
    show_image(class_image_eq, 'isodata_classification')
Exemplo n.º 7
0
def kmeans(image):
    from pyradar.classifiers.kmeans import kmeans_classification
    # number of clusters
    k = 4
    # max number of iterations
    iter_max = 1000
    # run K-Means
    class_image = kmeans_classification(image, k, iter_max)

    # equalize class image to 0:255
    class_image_eq = equalization_using_histogram(class_image)
    # save it
    show_image(class_image_eq, 'isodata_classification')
Exemplo n.º 8
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')
Exemplo n.º 9
0
def eq(image):
    # equalize img to 0:255
    image_eq = equalization_using_histogram(image)
    # save img in current directory
    show_image(image_eq, 'Equalized image via Hist')
Exemplo n.º 10
0
def dud(image):
    show_image(image, 'isodata_classification')
Exemplo n.º 11
0
def eq(image):
    # equalize img to 0:255
    image_eq = equalization_using_histogram(image)
    # save img in current directory
    show_image(image_eq, 'Equalized image via Hist')
Exemplo n.º 12
0
def dud(image):
    show_image(image, 'isodata_classification')