# texton = create_texton_feature(sat_image, ((25, 25), (50, 50), (100, 100)), image_name, n_clusters=n_clusters, cached=True)

            plt.close('all')
            print("Running feature set {}, image {}".format(
                feature_set, image_name))
            results_path = '{root}/results/jaccard/{fs}'.format(
                root=get_project_root(), fs=str(feature_set))
            try:
                os.makedirs(os.path.dirname(results_path + '/'), exist_ok=True)
            except OSError:
                pass

            X_test = get_x_matrix(test_image_loaded,
                                  image_name=image_name,
                                  feature_set=feature_set,
                                  window_size=main_window_size,
                                  cached=cached)
            y_test, real_mask = get_y_vector(mask_full_path,
                                             main_window_size,
                                             percentage_threshold,
                                             cached=False)

            # X, y = balance_dataset(X, y, class_ratio=class_ratio)
            # X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size, random_state=42, stratify=None)

            X_train, y_train, real_mask, groups_train = create_models(
                train_images,
                feature_set,
                base_path,
                main_window_size=main_window_size,
예제 #2
0

            # sift = create_sift_feature(sat_image, ((25, 25), (50, 50), (100, 100)), image_name, n_clusters=n_clusters,
            #                            cached=True)

            # lacunarity = create_lacunarity(sat_image, image_name, windows=((25, 25),), cached=True)
            lacunarity = Lacunarity(windows=lac_window_size, box_sizes=(lac_box_size,))
            feature_set.add(lacunarity, "LACUNARITY")
            # feature_set.add(pantex, "PANTEX")
            # feature_set.add(sift, "SIFT")

            classifier = RF_classifier()

            # del sat_image  # Free-up memory

            X = get_x_matrix(sat_image, image_name=image_name, feature_set=feature_set, window_size=main_window_size,
                             cached=True)

            print(X.shape)
            X = X[:, 1:]

            # X = np.mean(X, axis=3)

            ds, img, bands = load_from_file(image_file, WORLDVIEW3)
            img = normalize_image(img, bands)
            rgb_img = get_rgb_bands(img, bands)
            plt.figure()
            plt.imshow(rgb_img)
            plt.savefig(results_path + "/lacunarity_heatmap_image_{image_name}.png".format(
                image_name=image_name
            ))