Esempio n. 1
0
def display_details():
    # グラフの描画
    if display == True:
        dis = np.vstack((dis, np.array([precision, recall, f])))
        if (i + 1) % variety == 0:
            ax2.plot(dis[:, 0],
                     dis[:, 1],
                     "-o",
                     label='sigma = {}'.format(param[1]),
                     color='r')
            ax2.legend()
            dis = np.empty((0, 3), int)

    # rangeのscoreも出すとき
    if detail == True:
        pred_seed_img = rd.main(img, params[best])
        precision, recall, true_features, detect_img = ev.main(
            pred_seed_img, true_ror, label_img, true_features)
        range_p, range_r = get_detail_score(true_features, pred_seed_img)
        print 'Prc by range   : {}'.format(range_p)
        print 'Rcl by range   : {}'.format(range_r)

    # 検出結果を画像で出すとき
    if result_image == True:
        result_best = get_detect_img(img, detect_img)
        result_stock = get_detect_img(img, detect_stock)
        cv2.imshow('best result', result_best)
        cv2.imshow('total result', result_stock)
Esempio n. 2
0
def main(img, true_ror):
    '''
        args : src     ->  3ch, input image
               true_ror -> 1ch, ground-truth binary image
    '''
    ## get params
    params = get_params('test')
    scores = []
    pre2s = []
    recall2s = []
    
    ## True feature
    true_features = fe.main(img, true_ror.copy())
    true_models   = md.main(true_features, N=10)
    composition, size, shape = ad.main(true_features, true_models)    ; print 'Complete AD'
    raw_input()


    # ad.main()                       ; print 'Complete trueAD'
    for i, param in enumerate(params):
      if i == 1:  
        
        '''Target Detection'''
        print 'Start detection'
        pred_ror, pred_seed = rd.main(img, param=param)
        pred_features       = fe.main(img, pred_ror)      
        pred_models         = md.main(pred_features, N=10)
        # composition, size, shape = ad.main(pred_features, pred_models)    ; print 'Complete AD'
        
        '''Evaluate'''
        # pre, recall, f, detect_img = seedev.main(pred_seed, true_ror)
        # convex, pre2, recall2      = rgev.main(pred_ror, true_ror)
        
        '''Display results'''
        # display_3d(pred_features)
        display_3d(img, pred_features)
        display_models(pred_models[0:4], true_models[0:4], pred_features, true_features)
        # display_result(true_ror, param, pred_seed, detect_img, pre, recall, f, i, len(params))
        # display_result2(img, detect_img, pred_ror, true_ror, pred_seed) # 画像のスコア
        # display_result3(convex, pre2, recall2, param)
        # pre2s.append(pre2)
        # recall2s.append(recall2)
    plt.show()
Esempio n. 3
0
def main(img, true_ror):
    '''
        args : src     ->  3ch, input image
               true_ror -> 1ch, ground-truth binary image
    '''
    ## get params
    params = get_params('test')
    scores = []
    pre2s = []
    recall2s = []

    ## True feature
    true_features = fe.main(img, true_ror.copy())
    true_models = md.main(true_features, N=10)
    composition, size, shape = ad.main(true_features, true_models)
    print 'Complete AD'
    raw_input()

    # ad.main()                       ; print 'Complete trueAD'
    for i, param in enumerate(params):
        if i == 1:
            '''Target Detection'''
            print 'Start detection'
            pred_ror, pred_seed = rd.main(img, param=param)
            pred_features = fe.main(img, pred_ror)
            pred_models = md.main(pred_features, N=10)
            # composition, size, shape = ad.main(pred_features, pred_models)    ; print 'Complete AD'
            '''Evaluate'''
            # pre, recall, f, detect_img = seedev.main(pred_seed, true_ror)
            # convex, pre2, recall2      = rgev.main(pred_ror, true_ror)
            '''Display results'''
            # display_3d(pred_features)
            display_3d(img, pred_features)
            display_models(pred_models[0:4], true_models[0:4], pred_features,
                           true_features)
            # display_result(true_ror, param, pred_seed, detect_img, pre, recall, f, i, len(params))
            # display_result2(img, detect_img, pred_ror, true_ror, pred_seed) # 画像のスコア
            # display_result3(convex, pre2, recall2, param)
            # pre2s.append(pre2)
            # recall2s.append(recall2)
    plt.show()
Esempio n. 4
0
def display_details():
    # グラフの描画
    if display == True:
        dis = np.vstack((dis, np.array([precision,recall,f])))
        if (i+1)%variety == 0:
            ax2.plot(dis[:,0], dis[:,1], "-o",label='sigma = {}'.format(param[1]), color='r')
            ax2.legend()
            dis = np.empty((0,3), int)
    
    # rangeのscoreも出すとき
    if detail == True:
        pred_seed_img = rd.main(img, params[best])
        precision, recall, true_features, detect_img = ev.main(pred_seed_img, true_ror, label_img, true_features)
        range_p, range_r = get_detail_score(true_features, pred_seed_img)
        print 'Prc by range   : {}'.format(range_p)
        print 'Rcl by range   : {}'.format(range_r)
    
    # 検出結果を画像で出すとき
    if result_image == True:
        result_best = get_detect_img(img, detect_img)
        result_stock = get_detect_img(img, detect_stock)
        cv2.imshow('best result',result_best)
        cv2.imshow('total result',result_stock)
Esempio n. 5
0
def main(src, true_ror):
    '''
    '''

    img = copy.deepcopy(src)

    params, variety = get_params()
    true_ror, label_img, true_features = get_true_features(img, true_ror)

    for i, param in enumerate(params):

        ## Rock detection and evaluation
        pred_ror, pred_seed_img = rd.main(img, param)
        precision, recall, true_features, detect_img = ev.main(
            pred_seed_img, true_ror, label_img, true_features)
        f = 2. * recall * precision / (recall + precision)

        print '======================='
        print 'Seed threshold : {}'.format(int(param[0]))
        print 'Gabor sigma    : {}'.format(param[1])
        print 'Gabor bias     : {}'.format(param[2])
        print 'Sun direction  : {}π'.format(param[3] / np.pi)
        print 'Rock quantity  : {}'.format(np.amax(label_img))
        print 'Seed quantity  : {}'.format(len(np.nonzero(pred_seed_img)[0]))
        print 'Correct seeds  : {}'.format(true_features[:, 0].sum())
        print 'Detected rocks : {}'.format(
            (np.array(np.nonzero(true_features[:, 0]))).shape[1])
        print 'Precision      : {}'.format(round(precision, 3))
        print 'Recall         : {}'.format(round(recall, 3))
        print 'F-measure      : {}'.format(round(f, 3))
        print 'Ateempt number : {} / {}'.format(i + 1, params.shape[0])
        print '======================='

        results = np.vstack((results, np.array([precision, recall, f])))

        ## Initialization and renew
        detect_stock_list += true_features[:, 0]
        detect_stock[detect_img == 255] = 255
        true_features[:, 0] = 0

        # グラフの描画
        if display == True:
            dis = np.vstack((dis, np.array([precision, recall, f])))
            if (i + 1) % variety == 0:
                ax2.plot(dis[:, 0],
                         dis[:, 1],
                         "-o",
                         label='sigma = {}'.format(param[1]))
                ax2.legend()
                dis = np.empty((0, 3), int)

    # best scoreの表示
    best = np.argmax(results[:, 2])
    print '***** BEST SCORE ******'
    print 'Seed threshold : {}'.format(int(params[best][0]))
    print 'Gabor sigma    : {}'.format(params[best][1])
    print 'Gabor bias     : {}'.format(params[best][2])
    print 'Sun direction  : {}π'.format(params[best][3] / np.pi)
    print 'Precision      : {}'.format(round(results[best, 0], 3))
    print 'Recall         : {}'.format(round(results[best, 1], 3))
    print 'F-measure      : {}'.format(round(results[best, 2], 3))
    print 'Ateempt number : {} / {}'.format(best + 1, params.shape[0])
    print '***********************'

    # rangeのscoreも出すとき
    if detail == True:
        pred_ror, pred_seed_img = rd.main(img, params[best])
        precision, recall, true_features, detect_img = ev.main(
            pred_seed_img, true_ror, label_img, true_features)
        range_p, range_r = get_detail_score(true_features, pred_seed_img)
        print 'Prc by range   : {}'.format(range_p)
        print 'Rcl by range   : {}'.format(range_r)

    # 検出結果を画像で出すとき
    if result_image == True:
        result_best = get_detect_img(img, detect_img)
        result_stock = get_detect_img(img, detect_stock)
        cv2.imshow('best result', result_best)
        cv2.imshow('total result', result_stock)
Esempio n. 6
0
def main(src, true_ror):
    '''
    '''

    img = copy.deepcopy(src)
    
    params, variety = get_params()
    true_ror, label_img, true_features = get_true_features(img, true_ror)

    for i, param in enumerate(params):

        ## Rock detection and evaluation
        pred_ror, pred_seed_img = rd.main(img, param)
        precision, recall, true_features, detect_img = ev.main(pred_seed_img, true_ror, label_img, true_features)
        f = 2.*recall*precision / (recall+precision)

        print '======================='
        print 'Seed threshold : {}'.format(int(param[0]))
        print 'Gabor sigma    : {}'.format(param[1])
        print 'Gabor bias     : {}'.format(param[2])
        print 'Sun direction  : {}π'.format(param[3]/np.pi)
        print 'Rock quantity  : {}'.format(np.amax(label_img))
        print 'Seed quantity  : {}'.format(len(np.nonzero(pred_seed_img)[0]))
        print 'Correct seeds  : {}'.format(true_features[:,0].sum())
        print 'Detected rocks : {}'.format((np.array(np.nonzero(true_features[:,0]))).shape[1])
        print 'Precision      : {}'.format(round(precision, 3))
        print 'Recall         : {}'.format(round(recall   , 3))
        print 'F-measure      : {}'.format(round(f        , 3))
        print 'Ateempt number : {} / {}'.format(i+1,params.shape[0])
        print '======================='

        results = np.vstack((results, np.array([precision,recall,f])))

        ## Initialization and renew
        detect_stock_list += true_features[:,0]
        detect_stock[detect_img == 255] = 255
        true_features[:,0] = 0

        # グラフの描画
        if display == True:
            dis = np.vstack((dis, np.array([precision,recall,f])))
            if (i+1)%variety == 0:
                ax2.plot(dis[:,0], dis[:,1], "-o",label='sigma = {}'.format(param[1]))
                ax2.legend()
                dis = np.empty((0,3), int)
        
    # best scoreの表示
    best = np.argmax(results[:,2])
    print '***** BEST SCORE ******'
    print 'Seed threshold : {}'.format(int(params[best][0]))
    print 'Gabor sigma    : {}'.format(params[best][1])
    print 'Gabor bias     : {}'.format(params[best][2])
    print 'Sun direction  : {}π'.format(params[best][3]/np.pi)
    print 'Precision      : {}'.format(round(results[best,0], 3))
    print 'Recall         : {}'.format(round(results[best,1], 3))
    print 'F-measure      : {}'.format(round(results[best,2], 3))
    print 'Ateempt number : {} / {}'.format(best+1,params.shape[0])
    print '***********************'
    
    # rangeのscoreも出すとき
    if detail == True:
        pred_ror, pred_seed_img = rd.main(img, params[best])
        precision, recall, true_features, detect_img = ev.main(pred_seed_img, true_ror, label_img, true_features)
        range_p, range_r = get_detail_score(true_features, pred_seed_img)
        print 'Prc by range   : {}'.format(range_p)
        print 'Rcl by range   : {}'.format(range_r)
    
    # 検出結果を画像で出すとき
    if result_image == True:
        result_best = get_detect_img(img, detect_img)
        result_stock = get_detect_img(img, detect_stock)
        cv2.imshow('best result',result_best)
        cv2.imshow('total result',result_stock)