def setUp(self):
     subdirs = ["spectral_libraries", "usgs_splib07", "ASCIIdata"]
     self.usgs_dir = file_utils.get_path_from_subdirs(
         demo_data_base_dir, subdirs)
     self.test_spectrum_fname_part = "Cordierite-QtzMus_HS346.1B_ASDFRc_AREF.txt"
     self.asd_ascii_subdirs = ["ASCIIdata_splib07b_cvASD"]
     self.test_spectrum_dir = "ChapterS_SoilsAndMixtures"
Example #2
0
def run_pca():
    radiance_cube_fname = file_utils.get_path_from_subdirs(
        demo_data_base_dir, [
            "image_data", "hyperspectral", "cooke_city", "self_test", "HyMap",
            "self_test_rad.img"
        ])

    radiance_envi_image = ImageFactory.envi.from_gdal_file_and_point_calcs(
        radiance_cube_fname)
    radiance_image_data = radiance_envi_image.read_all_image_data_from_disk()

    print("")
    print("RUN PCA DEMO")

    n_pca_bands = 10
    pca_result = sip_2d.compute_image_cube_pca(radiance_image_data,
                                               n_components=n_pca_bands,
                                               whiten=True)

    for band_number in range(n_pca_bands):
        result = pca_result[:, :, band_number]
        save_image_fname = os.path.join(
            save_dir,
            "cooke_city_pca_band_" + str(band_number).zfill(5) + ".png")
        imageio.imwrite(save_image_fname, result)
        print("saved envi cube to: " + save_image_fname)
Example #3
0
 def setUp(self):
     print("")
     self.png_fullpath = file_utils.get_path_from_subdirs(
         demo_data_base_dir, [
             "image_data", "overhead_vehicle_data", "Potsdam_ISPRS",
             "top_potsdam_2_14_RGB.png"
         ])
     self.png_image_data = imread(self.png_fullpath)
     png_shape = self.png_image_data.shape
     self.ny = png_shape[0]
     self.nx = png_shape[1]
     self.nbands = png_shape[2]
 def setUp(self):
     subdirs = ["spectral_libraries", "usgs_splib07", "ASCIIdata"]
     self.usgs_dir = file_utils.get_path_from_subdirs(
         demo_data_base_dir, subdirs)
     self.test_spectrum_fname_part = "Cordierite-QtzMus_HS346.1B_ASDFRc_AREF.txt"
     self.aviris_ascii_subdirs = [
         "ASCIIdata_splib07b_cvAVIRISc1995",
         "ASCIIdata_splib07b_cvAVIRISc1996",
         "ASCIIdata_splib07b_cvAVIRISc1997",
         "ASCIIdata_splib07b_cvAVIRISc1998",
         "ASCIIdata_splib07b_cvAVIRISc1999",
         "ASCIIdata_splib07b_cvAVIRISc2000",
         "ASCIIdata_splib07b_cvAVIRISc2001",
         "ASCIIdata_splib07b_cvAVIRISc2005",
         "ASCIIdata_splib07b_cvAVIRISc2006",
         "ASCIIdata_splib07b_cvAVIRISc2009",
         "ASCIIdata_splib07b_cvAVIRISc2010",
         "ASCIIdata_splib07b_cvAVIRISc2011",
         "ASCIIdata_splib07b_cvAVIRISc2012",
         "ASCIIdata_splib07b_cvAVIRISc2013",
         "ASCIIdata_splib07b_cvAVIRISc2014"
     ]
     self.test_spectrum_dir = "ChapterS_SoilsAndMixtures"
Example #5
0
from resippy.utils import file_utils as file_utils
from resippy.utils import envi_utils
from resippy.image_objects.image_factory import ImageFactory
from resippy.spectral.spectrum_factories.spectrum_factory import SpectrumFactory
import resippy.spectral.spectral_image_processing_2d as sip_2d
import resippy.utils.image_utils.image_utils as image_utils
import numpy as np
import imageio
import seaborn
import os

import matplotlib.pyplot as plt

reflectance_cube_fname = file_utils.get_path_from_subdirs(
    demo_data_base_dir, [
        "image_data", "hyperspectral", "cooke_city", "self_test", "HyMap",
        "self_test_refl.img"
    ])

reflectance_envi_image = ImageFactory.envi.from_gdal_file_and_point_calcs(
    reflectance_cube_fname)
reflectance_image_data = reflectance_envi_image.read_all_image_data_from_disk()
reflectance_image_data = reflectance_image_data.astype(float) * 0.01
ny, nx, nbands = reflectance_image_data.shape

seaborn_color_palette = seaborn.color_palette("RdBu_r")

test_spectrum_fname = file_utils.get_path_from_subdirs(demo_data_base_dir, [
    "image_data", "hyperspectral", "cooke_city", "self_test", "SPL", "F1",
    "F1_l.txt"
])
import os


# choose a gsd
gsd_m = 0.5
# constants calculated from https://msi.nga.mil/MSISiteContent/StaticFiles/Calculators/degree.html
# based on approx latitude of center of images
gsd_lon = gsd_m / 81417.0
gsd_lat = gsd_m / 111095.0

# set up filename bundle for a frame, note that it is assumed that the band number is the last item in the filename

micasense_dir = file_utils.get_path_from_subdirs(demo_data_base_dir, ['image_data',
                                                                      'multispectral',
                                                                      'micasense',
                                                                      '20181019_hana',
                                                                      '1703',
                                                                      'micasense',
                                                                      'processed'
                                                                      ])


band_fname_dict = {}
for cam_num in range(1, 6):
    band_num = str(cam_num)
    band_fname_dict['band' + band_num] = \
        file_utils.get_path_from_subdirs(micasense_dir, ['merged', 'L0_IMG_0404_' + band_num + '.tif'])

# set up path to pix4d parameters used to build point calculator etc
params_dir = file_utils.get_path_from_subdirs(micasense_dir, ['pix4d_1703_mica_imgs85_1607',
                                                              '1_initial',
                                                              'params'])
Example #7
0
import resippy.utils.image_utils.image_utils as image_utils
import resippy.utils.file_utils as file_utils
from resippy.test_runner import demo_data_base_dir
from resippy.test_runner import demo_data_save_dir
import imageio
import os
import numpy as np

save_dir = os.path.join(demo_data_save_dir, "colormap_demos")
file_utils.make_dir_if_not_exists(save_dir)

png_fullpath = file_utils.get_path_from_subdirs(demo_data_base_dir, [
    "image_data", "overhead_vehicle_data", "Potsdam_ISPRS",
    "top_potsdam_2_14_RGB.png"
])


def main():
    image_data = imageio.imread(png_fullpath)
    image_data = image_data[:, :, 0:3]
    grayscale_image = image_data[:, :, 0]
    colormapped_image = image_utils.apply_colormap_to_grayscale_image(
        grayscale_image)
    imageio.imwrite(os.path.join(save_dir, "colormapped_image.png"),
                    colormapped_image)
    blended_image = np.asarray(image_utils.blend_images(
        image_data, colormapped_image),
                               dtype=np.uint8)
    imageio.imwrite(os.path.join(save_dir, "blended_image.png"), blended_image)

Example #8
0
import resippy.photogrammetry.ortho_tools as ortho_tools
from resippy.image_objects.image_factory import ImageFactory
from tests.demo_tests import demo_data_base_dir, demo_data_save_dir
from resippy.utils import file_utils as file_utils

import os

import logging

dg_dir = file_utils.get_path_from_subdirs(demo_data_base_dir, [
    "image_data", "digital_globe",
    "Tripoli_View-Ready_Stereo_8_Band_Bundle_30cm", "056082094030"
])

multispectral_image_fname_1 = file_utils.get_path_from_subdirs(
    dg_dir, [
        "056082094030_01_P001_MUL",
        "15AUG31100732-M2AS-056082094030_01_P001.TIF"
    ])

save_dir = os.path.join(demo_data_save_dir, "digital_globe_demos")
file_utils.make_dir_if_not_exists(save_dir)

# make the image object object
digital_globe_image = ImageFactory.digital_globe.view_ready_stereo.from_file(
    multispectral_image_fname_1)


def ortho_digital_globe_image():
    print("STARTING A DIGITAL GLOBE DEMO")
    nx = 1000
Example #9
0
import os
from resippy.image_objects.image_factory import ImageFactory
from resippy.test_runner import demo_data_base_dir
from resippy.test_runner import demo_data_save_dir
from resippy.utils import file_utils as file_utils


micasense_dir = file_utils.get_path_from_subdirs(demo_data_base_dir, ['image_data',
                                                                      'multispectral',
                                                                      'micasense',
                                                                      '20181019_hana',
                                                                      '1703',
                                                                      'micasense',
                                                                      'processed'
                                                                      ])

gtiff_full_path = file_utils.get_path_from_subdirs(micasense_dir,
                                                ['pix4d_1703_mica_imgs85_1607',
                                                 '3_dsm_ortho',
                                                 'pix4d_1704_mica_85_1607_dsm.tif'])

save_dir = os.path.join(demo_data_save_dir, "gtiff_demos")
file_utils.make_dir_if_not_exists(save_dir)


def create_maptiles():
    print("")
    print("CREATE MAPTILES DEMO")
    file_utils.make_dir_if_not_exists(save_dir)
    gtiff_image_object = ImageFactory.geotiff.from_file(gtiff_full_path)
    gtiff_image_object.create_map_tiles("/tmp/")
from resippy.utils import file_utils
import resippy.utils.image_utils.image_chipper as image_chipper
from resippy.utils.image_utils import image_utils

import numpy as np
from numpy import ndarray
import os
import logging

save_dir = os.path.join(demo_data_save_dir, "mmi_demos")
file_utils.make_dir_if_not_exists(save_dir)

micasense_dir = file_utils.get_path_from_subdirs(demo_data_base_dir, ['image_data',
                                                                      'multispectral',
                                                                      'micasense',
                                                                      '20181019_hana',
                                                                      '1703',
                                                                      'micasense',
                                                                      'processed'
                                                                      ])
band_fname_dict = {}
for cam_num in range(1, 6):
    band_num = str(cam_num)
    band_fname_dict['band' + band_num] = \
        file_utils.get_path_from_subdirs(micasense_dir, ['merged', 'L0_IMG_0404_' + band_num + '.tif'])


def mmi_window_demo():
    print("")
    print("STARTING A SLIDING WINDOW MUTUAL INFORMATION DEMO, THIS MIGHT TAKE A LITTLE BIT...")
    max_pixel_shift = 50
    n_steps = 10
import os
from resippy.test_runner import demo_data_base_dir
from resippy.test_runner import demo_data_save_dir
from resippy.utils import file_utils as file_utils
from resippy.utils.image_utils import image_mask_utils
from resippy.utils.image_utils import image_chipper
from resippy.utils import numpy_and_array_utils
from imageio import imread

png_fullpath = file_utils.get_path_from_subdirs(demo_data_base_dir, [
    "image_data", "overhead_vehicle_data", "Potsdam_ISPRS",
    "top_potsdam_2_14_RGB.png"
])

png_positive_mask_fullpath = file_utils.get_path_from_subdirs(
    demo_data_base_dir, [
        "image_data", "overhead_vehicle_data", "Potsdam_ISPRS",
        "top_potsdam_2_14_RGB_Annotated_Cars.png"
    ])

png_negative_mask_fullpath = file_utils.get_path_from_subdirs(
    demo_data_base_dir, [
        "image_data", "overhead_vehicle_data", "Potsdam_ISPRS",
        "top_potsdam_2_14_RGB_Annotated_Negatives.png"
    ])

save_dir_base = file_utils.get_path_from_subdirs(
    demo_data_save_dir, ["overhead_vehicles", "training_data"])
file_utils.make_dir_if_not_exists(save_dir_base)