def plot_partition(data, datat, C, A, AT): K = C.shape[1] colors = ["r", "g", "b", "y", "#444444"] for k in range(K): sel = pylab.find(A == k) selt = pylab.find(AT == k) vl_plotframe(data[:, sel], color=colors[k]) vl_plotframe(datat[:, selt], color=colors[k]) pylab.plot(C[0, :], C[1, :], "ko", markersize=14, linewidth=6) pylab.plot(C[0, :], C[1, :], "yo", markersize=10, linewidth=1)
def plot_partition(data, datat, C, A, AT): K = C.shape[1] colors = ['r', 'g', 'b', 'y', '#444444'] for k in range(K): sel = pylab.find(A==k) selt = pylab.find(AT==k) vl_plotframe(data[:,sel], color=colors[k]) vl_plotframe(datat[:,selt], color=colors[k]) pylab.plot(C[0,:],C[1,:],'ko', markersize=14, linewidth=6) pylab.plot(C[0,:],C[1,:],'yo', markersize=10, linewidth=1)
import vlfeat from vlfeat.plotop.vl_plotframe import vl_plotframe if __name__ == "__main__": """ VL_DEMO_SIFT_EDGE Demo: SIFT: edge treshold """ I = numpy.zeros([100, 500]) for i in 10 * (1 + numpy.arange(9)): d = numpy.round(i / 3.0) I[50 - d - 1 : 50 + d - 1, i * 5 - 1] = 1 I = numpy.array(I, "f", order="F") I = 2 * numpy.pi * 8 ** 2 * vlfeat.vl_imsmooth(I, 8) I = 255 * I I = numpy.array(I, "f", order="F") print "sift_edge_0" ter = [3.5, 5, 7.5, 10] for te in ter: f, d = vlfeat.vl_sift(I, peak_thresh=0.0, edge_thresh=te) pylab.figure() pylab.gray() pylab.imshow(I) vl_plotframe(f, color="k", linewidth=3) vl_plotframe(f, color="y", linewidth=2) pylab.show()
# -------------------------------------------------------------------- I = Image.open('../../../data/a.jpg') I = vlfeat.vl_rgb2gray(numpy.array(I)) I = numpy.array(I, 'f', order='F') # 'F' = column-major order! pylab.gray() pylab.imshow(I) print 'sift_basic_1' # -------------------------------------------------------------------- # Run SIFT # -------------------------------------------------------------------- f, d = vlfeat.vl_sift(I) sel = numpy.arange(f.shape[1]) shuffle(sel) vl_plotframe(f[:, sel[:50]], color='k', linewidth=3) vl_plotframe(f[:, sel[:50]], color='y') print 'sift_basic_2' # h3 = vl_plotsiftdescriptor(d(:,sel),f(:,sel)) ; # set(h3,'color','k','linewidth',2) ; # h4 = vl_plotsiftdescriptor(d(:,sel),f(:,sel)) ; # set(h4,'color','g','linewidth',1) ; # h1 = vl_plotframe(f(:,sel)) ; set(h1,'color','k','linewidth',3) ; # h2 = vl_plotframe(f(:,sel)) ; set(h2,'color','y','linewidth',2) ; # # vl_demo_print('sift_basic_3') ; # -------------------------------------------------------------------- # Custom keypoint
from vlfeat.test.vl_test_pattern import vl_test_pattern if __name__ == '__main__': # create pattern I = vl_test_pattern(1) ; # create frames (spatial sampling) ur = numpy.arange(0, I.shape[1], 5) vr = numpy.arange(0, I.shape[0], 5) [u,v] = numpy.meshgrid(ur, vr) f = numpy.array([u.ravel(), v.ravel()]) K = f.shape[1] f = numpy.vstack([f, 2 * numpy.ones([1, K]), 0 * numpy.ones([1, K])]) # convert frame to good format f = numpy.array(f, order='F') # compute sift f, d = vlfeat.vl_sift(numpy.array(I, 'f', order='F'), frames=f, orientations=True) # display results pylab.gray() pylab.imshow(I) vl_plotframe(f, color='k', linewidth=3) vl_plotframe(f, color='y', linewidth=2) pylab.show() print 'sift_or'