コード例 #1
0
def classifyImageSuperPixels( rgbImage, classifier, superPixelObj, ftype, aggtype, makeProbabilities ):
  outProbs = None

  # Get superpixels
  imgSuperPixelsMask = superPixelObj.m_labels
  imgSuperPixels = superPixelObj.m_nodes
  numberImgSuperPixels = len(imgSuperPixels)
  print "**Image contains", numberImgSuperPixels, "superpixels"

  # Get superpixel features
  # todo: replace with features.computeSuperPixelFeatures JRS
  spFtrs = features.computeSuperPixelFeatures( rgbImage, superPixelObj, ftype, aggtype )
  spLabels = classLabelsOfFeatures( spFtrs, classifier )

  if makeProbabilities:
    outProbs = classProbsOfFeatures( spFtrs, classifier )

  return (spLabels, outProbs)
コード例 #2
0
    superPixelCompactness = args.superPixelCompactness

    imgRGB = amntools.readImage(args.infile)

    # Turn image into superpixels.
    spix = superPixels.computeSuperPixelGraph(
        imgRGB, 'slic', [numberSuperPixels, superPixelCompactness])

    print 'Loading classifier...'
    assert args.clfrFn != None, 'No classifier filename specified!'

    clfr = pomio.unpickleObject(args.clfrFn)

    print 'Computing superpixel features...'
    ftrs = features.computeSuperPixelFeatures(imgRGB,
                                              spix,
                                              ftype='classic',
                                              aggtype='classic')

    print 'Computing class probabilities...'
    classProbs = classification.classProbsOfFeatures(ftrs,clfr,\
                                                     requireAllClasses=False)

    if args.verbose:
        plt.interactive(1)

        if adjProbs != None:
            plt.figure()
            plt.imshow(np.log(1 + adjProbs),
                       cmap=cm.get_cmap('gray'),
                       interpolation='none')
            plt.title('Adjacency probabilities')
コード例 #3
0
    numberSuperPixels = args.nbSuperPixels
    superPixelCompactness = args.superPixelCompactness


    imgRGB = amntools.readImage( args.infile )

    # Turn image into superpixels.
    spix = superPixels.computeSuperPixelGraph( imgRGB, 'slic', [numberSuperPixels,superPixelCompactness] )

    print 'Loading classifier...'
    assert args.clfrFn != None, 'No classifier filename specified!'
        
    clfr = pomio.unpickleObject(args.clfrFn)

    print 'Computing superpixel features...'
    ftrs = features.computeSuperPixelFeatures( imgRGB, spix, ftype='classic', aggtype='classic' )


    print 'Computing class probabilities...'
    classProbs = classification.classProbsOfFeatures(ftrs,clfr,\
                                                     requireAllClasses=False)

    if args.verbose:
        plt.interactive(1)

        if adjProbs != None:
            plt.figure()
            plt.imshow(np.log(1+adjProbs), cmap=cm.get_cmap('gray'), interpolation='none')
            plt.title('Adjacency probabilities')
            plt.waitforbuttonpress()