def features_for(im):
    from features import color_histogram
    im = mh.imread(im)
    img = mh.colors.rgb2grey(im).astype(np.uint8)
    return np.concatenate(
        [mh.features.haralick(img).ravel(),
         color_histogram(im)])
def features_for(im):
    from features import color_histogram

    im = mh.imread(im)
    img = mh.colors.rgb2grey(im).astype(np.uint8)
    return np.concatenate([mh.features.haralick(img).ravel(), color_histogram(im)])
예제 #3
0
chists = []

print(
    'This script will test (with cross-validation) classification of the simple 3 class dataset'
)
print('Computing features...')
# Use glob to get all the images
images = glob('{}/*.jpg'.format(basedir))

# We sort the images to ensure that they are always processed in the same order
# Otherwise, this would introduce some variation just based on the random
# ordering that the filesystem uses
for fname in sorted(images):
    imc = mh.imread(fname)
    haralicks.append(texture(mh.colors.rgb2grey(imc)))
    chists.append(color_histogram(imc))

    # Files are named like building00.jpg, scene23.jpg...
    labels.append(fname[:-len('xx.jpg')])

print('Finished computing features.')

haralicks = np.array(haralicks)
labels = np.array(labels)
chists = np.array(chists)

haralick_plus_chists = np.hstack([chists, haralicks])

# We use Logistic Regression because it achieves high accuracy on small(ish) datasets
# Feel free to experiment with other classifiers
clf = Pipeline([('preproc', StandardScaler()),
haralicks = []
labels = []
chists = []

print('This script will test (with cross-validation) classification of the simple 3 class dataset')
print('Computing features...')
# Use glob to get all the images
images = glob('{}/*.jpg'.format(basedir))

# We sort the images to ensure that they are always processed in the same order
# Otherwise, this would introduce some variation just based on the random
# ordering that the filesystem uses
for fname in sorted(images):
    imc = mh.imread(fname)
    haralicks.append(texture(mh.colors.rgb2grey(imc)))
    chists.append(color_histogram(imc))

    # Files are named like building00.jpg, scene23.jpg...
    labels.append(fname[:-len('xx.jpg')])

print('Finished computing features.')

haralicks = np.array(haralicks)
labels = np.array(labels)
chists = np.array(chists)

haralick_plus_chists = np.hstack([chists, haralicks])


# We use Logistic Regression because it achieves high accuracy on small(ish) datasets
# Feel free to experiment with other classifiers
def chist(fname):
    from features import chist as color_histogram
    im = mh.imread(fname)
    return color_histogram(im)
def chist(fname):
    from features import chist as color_histogram
    im = mh.imread(fname)
    return color_histogram(im)