Example #1
0
    def seed_method(method,File,stack,outFile,corFile=''):
        SeedingDone = 'no'
        next_method = method_default
        M = stack != 0

        if   method == 'manual':
            SeedingDone = seed_manual(File,stack,outFile)
            if SeedingDone == 'no':
                next_method = method_default
                print_warning(next_method)

        elif method == 'max_coherence':
            try:    SeedingDone = seed_max_coherence(File,M,outFile,corFile)
            except: SeedingDone = seed_max_coherence(File,M,outFile)
            if SeedingDone == 'no':
                next_method = 'random'
                print_warning(next_method)

        elif method == 'random':
            y,x = random_selection(stack)
            seed_xy(File,x,y,outFile)
            SeedingDone = 'yes'

        elif method == 'global_average':
            print '\n---------------------------------------------------------'
            print 'Automatically Seeding using Global Spatial Average Value '
            print '---------------------------------------------------------'
            print 'Calculating the global spatial average value for each epoch'+\
                  ' of all valid pixels ...'
            box = (0,0,width,length)
            meanList = ut.spatial_mean(File,M,box)
            seed_file(File,outFile,meanList,'','')
            SeedingDone = 'yes'

        return SeedingDone, next_method
Example #2
0
def seed_xy(File,x,y,outName=''):
    ## Seed Input File with reference on point (y,x)
    print 'Referencing input file to pixel: (%d, %d)'%(y,x)
    ##4-tuple defining the left, upper, right, and lower pixel coordinate [optional]
    box = (x,y,x+1,y+1)

    #####  IO Info
    atr = readfile.read_attributes(File)
    k = atr['FILE_TYPE']
    if outName == '':  outName = 'Seeded_'+os.path.basename(File)

    ##### Mask
    length = int(atr['FILE_LENGTH'])
    width  = int(atr['WIDTH'])
    mask = np.ones((length,width))
    
    ## Read refernce value
    refList = ut.spatial_mean(File,mask,box)

    ## Seeding
    seed_file(File,outName,refList,x,y)

    return 1