featuresLines.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pyImageClassification 作者: tyiannak 项目源码 文件源码
def scriptDemo():
    dirName = "demoData/lineDemo"
    types = ('*.jpg', )
    imageFilesList = []
    for files in types:
        imageFilesList.extend(glob.glob(os.path.join(dirName, files)))

    imageFilesList = sorted(imageFilesList)

    Features = np.zeros( (len(imageFilesList), 7) )
    labels = []
    for i, f in enumerate(imageFilesList):      
        print f 
        if ntpath.basename(f)[0:5]=="noPer":
            labels.append(0)
        else:
            labels.append(1)        
        img = cv2.imread(f, cv2.CV_LOAD_IMAGE_COLOR)    # read image
        [F, names] = getLineFeatures(img)
        Features[i,:] = F

    FeaturesPrespective = Features[:,4:7];

    fig = plt.figure()
    color = ["ro","gx"]
    labels = np.array(labels)
    ax = fig.add_subplot(111, projection='3d')

    ax.plot(FeaturesPrespective[np.nonzero(labels==0)[0],0], FeaturesPrespective[np.nonzero(labels==0)[0],1], FeaturesPrespective[np.nonzero(labels==0)[0],2], color[0], label='Non Perspective')
    ax.plot(FeaturesPrespective[np.nonzero(labels==1)[0],0], FeaturesPrespective[np.nonzero(labels==1)[0],1], FeaturesPrespective[np.nonzero(labels==1)[0],2], color[1], label='Perspective')

    ax.set_xlabel('Close Intersections - 5%')
    ax.set_ylabel('Close Intersections - 20%')
    ax.set_zlabel('Acute Angles')

    plt.legend(loc='upper left', numpoints=1)

    plt.show()

    for f in range(Features.shape[0]):
        print "{0:.4f}\t{1:.4f}\t{2:.4f}".format(Features[f, 4], Features[f, 5], Features[f, 6])


# For generating figures for paper
#scriptDemo()

# test intersection:
#A1 = np.array([0.0,0.0])
#A2 = np.array([4.0,2.0])
#B1 = np.array([1.0,1.2])
#B2 = np.array([2.0,1.0])
#plt.plot([A1[0], A2[0]], [A1[1],A2[1]])
#plt.plot([B1[0], B2[0]], [B1[1],B2[1]])
#[X, Y] = seg_intersect(A1, A2, B1, B2)
#print X, Y
#plt.plot(X, Y, '*');
#plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号