# generate features imagePixelFeatures = FeatureGenerator.generatePixelFeaturesForImage(ex.m_img) # For each feature, how many distinct values? for i in range(imagePixelFeatures.shape[1]): print "Feature %d has %d distinct values" \ % (i, len(np.unique( imagePixelFeatures[:,i])) ) # Plot a selection of features sel = np.arange(26,30) # sel = range(80,86) # colours have to be on range 0-1 plt.figure() # just plot some of the data for clarity nbpts = 2000 ptsz = 5 whichPts = np.random.choice( imagePixelFeatures.shape[0], nbpts, replace=False) # python weirdness, can't index from 2 lists at once... subset = imagePixelFeatures[whichPts,:] subset = subset[:,sel] labelSubset = np.reshape(ex.m_gt, (imagePixelFeatures.shape[0],1))[whichPts].squeeze() print labelSubset.shape # todo: fix bug, displayed labels not right, car cluster should be lower right amntools.gplotmatrix( subset,\ labelSubset, \ #ex.m_gt.flatten(1)[whichPts], \ msize=ptsz, classColours=clrs) plt.show()
if args.labs.endswith('.pkl'): labs = pomio.unpickleObject( args.labs ) else: labs = pomio.readMatFromCSV( args.labs ).astype(np.int32) # show labels if labs != None: plt.figure() plt.hist( labs, pomio.getNumClasses() ) plt.title('Class counts') plt.xticks( range(pomio.getNumClasses()), pomio.getClasses()[:pomio.getNumClasses()], size='small' ) # show at most 9 features at once fstarts = range( args.nstart, D, args.nshow ) plt.figure() for fs in fstarts: fend = min(D-1,fs+args.nshow-1) print ' Displaying features %d-%d:' % (fs, fend) rng = range( fs, fend+1 ) fnames = [ 'F%d' % x for x in rng ] amntools.gplotmatrix( ftrs[:,rng], labs, featureNames=fnames ) plt.waitforbuttonpress() plt.interactive(0) plt.show()
imagePixelFeatures = FeatureGenerator.generatePixelFeaturesForImage(ex.m_img) # For each feature, how many distinct values? for i in range(imagePixelFeatures.shape[1]): print "Feature %d has %d distinct values" \ % (i, len(np.unique( imagePixelFeatures[:,i])) ) # Plot a selection of features sel = np.arange(12, 29, 2) # sel = range(80,86) # colours have to be on range 0-1 plt.figure() # just plot some of the data for clarity nbpts = 2000 ptsz = 5 whichPts = np.random.choice(imagePixelFeatures.shape[0], nbpts, replace=False) # python weirdness, can't index from 2 lists at once... subset = imagePixelFeatures[whichPts, :] subset = subset[:, sel] labelSubset = np.reshape(ex.m_gt, (imagePixelFeatures.shape[0], 1))[whichPts].squeeze() print labelSubset.shape # todo: fix bug, displayed labels not right, car cluster should be lower right amntools.gplotmatrix( subset,\ labelSubset, \ #ex.m_gt.flatten(1)[whichPts], \ msize=ptsz, classColours=clrs) plt.show()
labs = None else: if args.labs.endswith('.pkl'): labs = pomio.unpickleObject(args.labs) else: labs = pomio.readMatFromCSV(args.labs).astype(np.int32) # show labels if labs != None: plt.figure() plt.hist(labs, pomio.getNumClasses()) plt.title('Class counts') plt.xticks(range(pomio.getNumClasses()), pomio.getClasses()[:pomio.getNumClasses()], size='small') # show at most 9 features at once fstarts = range(args.nstart, D, args.nshow) plt.figure() for fs in fstarts: fend = min(D - 1, fs + args.nshow - 1) print ' Displaying features %d-%d:' % (fs, fend) rng = range(fs, fend + 1) fnames = ['F%d' % x for x in rng] amntools.gplotmatrix(ftrs[:, rng], labs, featureNames=fnames) plt.waitforbuttonpress() plt.interactive(0) plt.show()