VisFeats is a library for extracting global visual features from images.
VisFeats is installable via PyPI:
pip install visfeatsOr via GitHub (for the latest development version):
pip install git+https://github.com/ncc-brain/VisFeats.gitTo use VisFeats, first load an image using PIL:
from PIL import Image
image = Image.open("path/to/your/image.jpg")All functions in VisFeats take a PIL Image.Image as input and return the corresponding feature values. Available features are described below.
Use extract_all_features to collect all package-level features, or pass a
feature name or list of names to select a subset. The result is a flat
dictionary.
from visfeats import extract_all_features
features = extract_all_features(image, features=["rms", "hsv_features"])Chromatic features describe color in HSV (Hue, Saturation, Value) space, including channel means and entropies. The hsv_features function returns a dictionary with six keys:
hue_meansaturation_meanvalue_meanhue_entropysaturation_entropyvalue_entropy
from visfeats import hsv_features
features = hsv_features(image)Spatial frequency features capture the distribution of different spatial frequencies in an image, which relate to the level of detail and texture. The spatial_frequency_features function extracts these features:
fourier_slopefourier_deviationdimensionalityspectral_centroidspectral_variance
from visfeats import spatial_frequency_features
features = spatial_frequency_features(image)While memorability is often considered a subjective property, recent research has shown that it can be predicted from image content. Here the memorability_resmem function estimates intrinsic memorability using the pretrained ResMem model described by Needell and Bainbridge (2022).
ResMem is an optional dependency. It can be installed along with VisFeats using:
pip install "visfeats[resmem]"Or separately with:
pip install resmemThen you can use the memorability_resmem function to estimate the memorability of an image:
from visfeats import memorability_resmem
resmem_score = memorability_resmem(image)The rms function computes the root-mean-square contrast as the population standard deviation of the image's grayscale pixel intensities.
from visfeats import rms
rms_contrast = rms(image)The compressibility_pillow function estimates how compressible an image is as the negative encoded size in bits per pixel, using lossless PNG encoding in memory by default. Values closer to 0 indicate a more compressible image.
from visfeats import compressibility_pillow
compressibility = compressibility_pillow(image)