当前位置: 首页>>代码示例>>Python>>正文


Python RectangleSelector.image方法代码示例

本文整理汇总了Python中matplotlib.widgets.RectangleSelector.image方法的典型用法代码示例。如果您正苦于以下问题:Python RectangleSelector.image方法的具体用法?Python RectangleSelector.image怎么用?Python RectangleSelector.image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.widgets.RectangleSelector的用法示例。


在下文中一共展示了RectangleSelector.image方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_keypoints

# 需要导入模块: from matplotlib.widgets import RectangleSelector [as 别名]
# 或者: from matplotlib.widgets.RectangleSelector import image [as 别名]
def draw_keypoints(img, keypoints, threshold, inter = True, color = 1):
    
    scales = ftext.getImageScales()
    #s = 100
    
    octaves = np.unique( keypoints[:, 2])
    if octaves.shape[0] == 0:
        return
    maxOctave = np.max(octaves)
    images = []
    selectors = []
    drawers = []
    for i in range(int(maxOctave) + 1):
        scale = scales[i]
        dst = ftext.getImageAtScale(i)
        cv2.imwrite("/tmp/pycv-{0}.png".format(i), dst)
        if color == 1:
            images.append(cv2.cvtColor(dst, cv2.COLOR_BGR2RGB))
        else:
            '''
            shape = img.shape
            shapet = ( shape[0] * scale, shape[1] * scale) 
            dst = np.zeros(shapet, dtype=np.uint8)
            dst = cv2.resize(img, (0,0), fx=scale, fy=scale)
            images.append(cv2.cvtColor(dst, cv2.COLOR_BGR2RGB))
            '''
            images.append(dst)
            
            #cv2.imshow("img", dst)
            #cv2.waitKey(0)
        
    
    ax_tuple = []
       
    for i in range(int(maxOctave) + 1):
        f = plt.figure(num = i)
        ax = f.add_subplot(111)
        ax_tuple.append(ax)
        
        plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, hspace = 0, wspace = 0)
        plt.margins(0,0)
        
        #tmp = cv2.cvtColor(, cv2.COLOR_GRAY2RGB)
        ax_tuple[i].imshow(images[i], interpolation='nearest', cmap=mpl.cm.gray)
        ax_tuple[i].grid(True)
        ax_tuple[i].axis('off') 
        ax_tuple[i].set_xlim([0, images[i].shape[1]])
        ax_tuple[i].set_ylim([images[i].shape[0], 0])
        ax_tuple[i].axes.get_xaxis().set_ticks([])
        ax_tuple[i].axes.get_yaxis().set_ticks([])
        
        maskOct = keypoints[:, 2] == i
        octIdx = np.nonzero(maskOct)
        octavePoints = keypoints[keypoints[:, 2] == i, :]
        octavePoints[:, 0] *= scales[i]
        octavePoints[:, 1] *= scales[i]
        octavePoints[:, 5] *= scales[i]
        octavePoints[:, 6] *= scales[i]
        octavePoints[:, 7] *= scales[i]
        octavePoints[:, 8] *= scales[i]
        style = 'rx'
        c = 'red'
        if len(octavePoints) > 0 and octavePoints.shape[1] > 9:
            for k in range(6):
                maski = octavePoints[:, 9] == k + 1
                if k == 1:
                    style = "rv"
                if k == 2:
                    style = "ro"
                if k == 4:
                    style = "bo"
                    c = 'blue'
                if k == 5:
                    style = "yo"
                    continue
                
                if drawGrayScale:
                    style = 'wv'
                    if k == 1:
                        style = "wv"
                    if k == 2:
                        style = "wv"
                    if k == 4:
                        style = "wo"
                        c = 'blue'
                    c = style
                
                ax_tuple[i].scatter(octavePoints[maski, 0], octavePoints[maski, 1],c=c, s=s )
                #ax_tuple[i].plot(octavePoints[maski, 0], octavePoints[maski, 1], style, markersize = 10) 
        else:
            ax_tuple[i].plot(octavePoints[:, 0], octavePoints[:, 1], style)
        #ax_tuple[i].plot(octavePoints[:, 6] * scales[i], octavePoints[:, 7] * scales[i], 'bo')
        #for j in range( octavePoints.shape[0] ):
        #    ax_tuple[i].plot([octavePoints[j,0] * scales[i], octavePoints[j,6]* scales[i]], [octavePoints[j,1] * scales[i], octavePoints[j,7]* scales[i]], 'r-')
        if inter:
            rs = RectangleSelector(ax_tuple[i], line_select_callback,
                                       drawtype='box', useblit=True,
                                       button=[1,3], # don't use middle button
                                       minspanx=5, minspany=5,
                                       spancoords='pixels')
#.........这里部分代码省略.........
开发者ID:AAAyag,项目名称:FASText,代码行数:103,代码来源:vis.py


注:本文中的matplotlib.widgets.RectangleSelector.image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。