Esempio n. 1
0
def GetImageSubset(subsetparameters, data, dimensions):
    #------------------------------------------------------------------
    # Create square image subset from predefined corner points
    #------------------------------------------------------------------
    Point = subsetparameters.Point

    # get and scale image subset
    BoxRange = dimensions.BoxRange
    BoxRange = BoxRange.astype(int)
    image = data.image[Point[1] - BoxRange[0]:Point[1] + BoxRange[1],
                       Point[0] - BoxRange[0]:Point[0] + BoxRange[1]]
    image = IP.ScaleImage(image, 8)

    # get and store corresponding coordinates
    easting = data.coordinates.easting[Point[1] - BoxRange[0]:Point[1] +
                                       BoxRange[1], Point[0] -
                                       BoxRange[0]:Point[0] + BoxRange[1]]
    northing = data.coordinates.northing[Point[1] - BoxRange[0]:Point[1] +
                                         BoxRange[1], Point[0] -
                                         BoxRange[0]:Point[0] + BoxRange[1]]
    coordinates = CL.Coordinates(northing, easting)

    #store subset data
    FlagFlip = IP.CheckImageOrientation(coordinates)
    subset = CL.Subset(Point, image, coordinates, data.resolution, FlagFlip)

    return subset
Esempio n. 2
0
def GetFFTBoxes(subsetparameters, data, dimension):

    #---------------------------------------------------------------------------------------------------------------
    # Create list of overlapping subset images to estimate spectrum at a given grid point (center of main subset)
    #---------------------------------------------------------------------------------------------------------------

    # initialisation
    #images, northings, eastings= [],[],[]
    Subsets = []
    # Get the various subset images centers (box defined with an offset from the main subset, the overlapping is controlled by the offset)
    offset = subsetparameters.Shift * dimension.BoxRange
    subset_centers = GetSubsetCenters(subsetparameters.Point, offset,
                                      subsetparameters.BoxNb)

    # get information on subsets (coordinates, image footprint)
    for i in subset_centers:
        # get subset
        subsetparameters.Point = i
        subset = GetImageSubset(subsetparameters, data, dimension)
        # scale image
        image = IP.ScaleImage(subset.image, 8)
        coordinates = CL.Coordinates(subset.coordinates.northing,
                                     subset.coordinates.easting)
        FlagFlip = IP.CheckImageOrientation(coordinates)
        subsets = CL.Subset(i, image, coordinates, data.resolution, FlagFlip)
        Subsets.append(subsets)
        """
		# concatenate data
		images.append(image); eastings.append(subset.coordinates.easting); northings.append(subset.coordinates.northing)
		
	#store data
	coordinates = Coordinates(northings,eastings)
	subsets = Subset(subset_centers, images, coordinates, data.resolution) 
	"""

    return Subsets
Esempio n. 3
0
def RadialSpectrum(parameters, subset_input):
    #--------------------------
    # A) Subset Processing
    #--------------------------

    # scale sub-images
    IP_Parameters = parameters.SubsetProcessingParameters
    image = IP.ScaleImage(subset_input.image, IP_Parameters.IntensityType)
    subset = CL.Subset(subset_input.CenterPoint, image,
                       subset_input.coordinates, subset_input.resolution,
                       subset_input.FlagFlip)
    #stretch contrast
    if IP_Parameters.ConstrastStretchFlag > 0:
        image = IP.ContrastStretch(image, IP_Parameters.IntensityType)
        subset = CL.Subset(subset.CenterPoint, image, subset.coordinates,
                           subset.resolution, subset.FlagFlip)
    #--------------------------
    # B) Subset Spectrum
    #--------------------------
    Image_Spectrum = ImageSpectrum(IP_Parameters, subset)

    #--------------------------
    # C) Direction Estimate
    #--------------------------
    # determine radius of influence
    R, _, _ = Influence_Radius(Image_Spectrum)
    DE_Parameters = parameters.DirectionEstimateParameters
    direction = DirectionEstimate(DE_Parameters, subset, Image_Spectrum)

    #--------------------------------------
    # D) Apply Butterworth Elliptic Filter
    #-------------------------------------
    IF_Parameters = parameters.FilterParameters
    DE_Parameters = parameters.DirectionEstimateParameters
    if IF_Parameters.FlagFilter:
        FilteredImage = ImageFilter(IF_Parameters, subset, direction)
        image = IP.ScaleImage(FilteredImage, 32)
        subset = CL.Subset(subset.CenterPoint, image, subset.coordinates,
                           subset.resolution, subset.FlagFlip)

    #------------------------------
    # E) Perform Image Padding
    #------------------------------
    RI_Parameters = parameters.SpectrumParameters.WaveSpectrumParameters

    #---------------------------------------------------
    # F) Re-Compute Image Spectrum and wave direction
    #----------------------------------------------------
    Image_Spectrum = ImageSpectrum(IP_Parameters, subset)
    direction = DirectionEstimate(DE_Parameters, subset, Image_Spectrum)

    #------------------------------------------------
    # G) Process Spectrum
    #------------------------------------------------

    Spectrum = Image_Spectrum.Spectrum
    k = Image_Spectrum.k
    mask = MaskPlot(R, subset)
    Spectrum[mask] = 0

    #---------------------------------------------
    # H) Compute radial integration and
    #---------------------------------------------
    Rr, RadialIntegration = RadialProjection(Spectrum)

    #---------------------------------------------
    # I) Evaluate k-axis in agreement with Radius
    #---------------------------------------------
    dk = np.sum(np.diff(k)) / (k.shape[0] - 1)
    kr = Rr * dk
    """	
	fig, ax = plt.subplots(1)
	ax.plot(kr, RadialIntegration)
	ax.plot(kr, RadialIntegration,'or')
	plt.show()	
	"""

    #---------------------------------------------
    # I) store data
    #---------------------------------------------
    Spectrum = CL.SpectrumData(kr, RadialIntegration)
    subset_output = subset
    Spectrum_Computed_Data = CL.SpectrumComputedData(direction, Spectrum,
                                                     Image_Spectrum,
                                                     subset_output)

    return Spectrum_Computed_Data
Esempio n. 4
0
def SubsetSpectrum(parameters, subset_input):
    #--------------------------------------------------------------------------------------
    # function that process a given subset image estimate the wave incident direction
    # and compute the wave spectrum
    #--------------------------------------------------------------------------------------

    #--------------------------
    # A) Subset Processing
    #--------------------------
    # scale sub-images
    IP_Parameters = parameters.SubsetProcessingParameters
    image = IP.ScaleImage(subset_input.image, IP_Parameters.IntensityType)
    subset = CL.Subset(subset_input.CenterPoint, image,
                       subset_input.coordinates, subset_input.resolution,
                       subset_input.FlagFlip)

    #stretch contrast
    if IP_Parameters.ConstrastStretchFlag:
        image = IP.ContrastStretch(image, IP_Parameters.IntensityType)
        subset = CL.Subset(subset.CenterPoint, image, subset.coordinates,
                           subset.resolution, subset.FlagFlip)
    #--------------------------
    # B) Subset Spectrum
    #--------------------------
    Image_Spectrum = ImageSpectrum(IP_Parameters, subset)

    #--------------------------
    # C) Direction Estimate
    #--------------------------
    DE_Parameters = parameters.DirectionEstimateParameters
    direction = DirectionEstimate(DE_Parameters, subset, Image_Spectrum)

    #--------------------------------------
    # D) Apply Butterworth Elliptic Filter
    #-------------------------------------
    IF_Parameters = parameters.FilterParameters
    if IF_Parameters.FlagFilter:
        FilteredImage = ImageFilter(IF_Parameters, subset, direction)
        image = IP.ScaleImage(FilteredImage, 32)
        subset = CL.Subset(subset.CenterPoint, image, subset.coordinates,
                           subset.resolution, subset.FlagFlip)
        Image_Spectrum = ImageSpectrum(IP_Parameters, subset)

        #---------------------------
        # C1) Direction re-estimate
        #---------------------------
        DE_Parameters = parameters.DirectionEstimateParameters
        direction = DirectionEstimate(DE_Parameters, subset, Image_Spectrum)
    #---------------------------------------------
    # E) Extract Wave Series and Compute Spectrum
    #---------------------------------------------
    SP_Parameters = parameters.SpectrumParameters.WaveSpectrumParameters
    K, Ks, S, Sp, Sstd = WavesMeanSpectrum(SP_Parameters, subset, direction)
    #---------------------------------------------
    # F) Store data
    #---------------------------------------------
    Spectrum = CL.SpectrumData(Ks, Sp)
    subset_output = subset
    Spectrum_Computed_Data = CL.SpectrumComputedData(direction, Spectrum,
                                                     Image_Spectrum,
                                                     subset_output)

    return Spectrum_Computed_Data