def show_hist_submaxima(hist_, edges=None, centers=None, maxima_thresh=.8, pnum=(1, 1, 1)): r""" For C++ to show data Args: hist_ (?): edges (None): centers (None): CommandLine: python -m vtool.histogram --test-show_hist_submaxima --show python -m pyhesaff._pyhesaff --test-test_rot_invar --show python -m vtool.histogram --test-show_hist_submaxima --dpath figures --save ~/latex/crall-candidacy-2015/figures/show_hist_submaxima.jpg Example: >>> # DISABLE_DOCTEST >>> import plottool as pt >>> from vtool.histogram import * # NOQA >>> # build test data >>> hist_ = np.array(list(map(float, ut.get_argval('--hist', type_=list, default=[1, 4, 2, 5, 3, 3])))) >>> edges = np.array(list(map(float, ut.get_argval('--edges', type_=list, default=[0, 1, 2, 3, 4, 5, 6])))) >>> maxima_thresh = ut.get_argval('--maxima_thresh', type_=float, default=.8) >>> centers = None >>> # execute function >>> show_hist_submaxima(hist_, edges, centers, maxima_thresh) >>> pt.show_if_requested() """ #print(repr(hist_)) #print(repr(hist_.shape)) #print(repr(edges)) #print(repr(edges.shape)) #ut.embed() import plottool as pt #ut.embed() if centers is None: centers = hist_edges_to_centers(edges) bin_colors = pt.get_orientation_color(centers) pt.figure(fnum=pt.next_fnum(), pnum=pnum) POLAR = False if POLAR: pt.df2.plt.subplot(*pnum, polar=True, axisbg='#000000') pt.draw_hist_subbin_maxima(hist_, centers, bin_colors=bin_colors, maxima_thresh=maxima_thresh) #pt.gca().set_rmax(hist_.max() * 1.1) #pt.gca().invert_yaxis() #pt.gca().invert_xaxis() pt.dark_background() #if ut.get_argflag('--legend'): # pt.figure(fnum=pt.next_fnum()) # centers_ = np.append(centers, centers[0]) # r = np.ones(centers_.shape) * .2 # ax = pt.df2.plt.subplot(111, polar=True) # pt.plots.colorline(centers_, r, cmap=pt.df2.plt.get_cmap('hsv'), linewidth=10) # #ax.plot(centers_, r, 'm', color=bin_colors, linewidth=100) # ax.set_rmax(.2) # #ax.grid(True) # #ax.set_title("Angle Colors", va='bottom') title = ut.get_argval('--title', default='') import plottool as pt pt.set_figtitle(title)
def TEST_figure1(wpatch, gradx, grady, gmag, gori, hist, centers): from plottool import draw_func2 as df2 import plottool import vtool.patch as ptool print('[rotinvar] 4) Draw histogram with interpolation annotations') fnum = 1 gorimag = plottool.color_orimag(gori, gmag, True) nRow, nCol = (2, 7) df2.figure(fnum=1, pnum=(nRow, 1, nRow), doclf=True, docla=True) plottool.draw_hist_subbin_maxima(hist, centers) df2.set_xlabel('grad orientation (radians)') df2.set_ylabel('grad magnitude') df2.set_title('dominant orientations') print('[rotinvar] 5) Show patch, gradients, magintude, and orientation') df2.imshow(wpatch, pnum=(nRow, nCol, 1), fnum=fnum, title='patch') df2.draw_vector_field(gradx, grady, pnum=(nRow, nCol, 2), fnum=fnum, title='gori (vec)') df2.imshow(gorimag, pnum=(nRow, nCol, 3), fnum=fnum, title='gori (col)') df2.imshow(np.abs(gradx), pnum=(nRow, nCol, 4), fnum=fnum, title='gradx') df2.imshow(np.abs(grady), pnum=(nRow, nCol, 5), fnum=fnum, title='grady') df2.imshow(gmag, pnum=(nRow, nCol, 6), fnum=fnum, title='gmag') gpatch = ptool.gaussian_patch(shape=gori.shape) df2.imshow(gpatch * 255, pnum=(nRow, nCol, 7), fnum=fnum, title='gauss weights', cmap_='hot') #gpatch3 = np.dstack((gpatch, gpatch, gpatch)) #df2.draw_vector_field(gradx * gpatch, grady * gpatch, pnum=(nRow, nCol, 8), fnum=fnum, title='gori (vec)') #df2.imshow(gorimag * gpatch3, pnum=(nRow, nCol, 9), fnum=fnum, title='gori (col)') #df2.imshow(gradx * gpatch, pnum=(nRow, nCol, 10), fnum=fnum, title='gradx') #df2.imshow(grady * gpatch, pnum=(nRow, nCol, 11), fnum=fnum, title='grady') #df2.imshow(gmag * gpatch, pnum=(nRow, nCol, 12), fnum=fnum, title='gmag') return locals()