Skip to content
ncc-brainPublic

About

Extraction of global visual features from images

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

VisFeats: Extraction of Global Visual Features from Images

Ruff Python Version

VisFeats is a library for extracting global visual features from images.

Installation

VisFeats is installable via PyPI:

pip install visfeats

Or via GitHub (for the latest development version):

pip install git+https://github.com/ncc-brain/VisFeats.git

Usage

To 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.

Extract multiple features

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"])

Mean and entropy of HSV channels

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_mean
  • saturation_mean
  • value_mean
  • hue_entropy
  • saturation_entropy
  • value_entropy
from visfeats import hsv_features
features = hsv_features(image)

Spatial frequency features

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_slope
  • fourier_deviation
  • dimensionality
  • spectral_centroid
  • spectral_variance
from visfeats import spatial_frequency_features
features = spatial_frequency_features(image)

Memorability

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 resmem

Then you can use the memorability_resmem function to estimate the memorability of an image:

from visfeats import memorability_resmem
resmem_score = memorability_resmem(image)

Other features

RMS contrast

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)

Compressibility

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)

About

Extraction of global visual features from images

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages