Gabrock94 / pyaesthetics

A python package to extract visual features about the aesthetic appearance from still images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logo

pyaesthetics

GitHub release PyPI PyPI pyversions PyPI status PyPI downloads Downloads Documentation Status DOI

Pyaesthetics (formlerly known as PrettyWebsite) is a python package designed to estimate visual features concerning the aesthetic appearance of a still image.

Features

The module can estimate the following features:

  • Brightness (in both the BT709 and BT601 standards)
  • Contrast (RMS or Michelson contrast)
  • Saturation
  • Visual Complexity (either by using the weight of the image or by Quadratic Tree Decomposition)
  • Simmetry (using Quadratic Tree Decomposition)
  • Colorfulness (in both the HSV and RGB color spaces)
  • Presence and number of human faces
  • Color distribution
  • Number of images within the image
  • Surface of visual and textual areas within the image
  • Ratio between visual and textual areas

Installation

pyaesthetics can be installed using pip:

pip install pyaesthetics

or manually by downloading or cloning the repository and, from the root folder of the project, running:

python setup.py pyaesthetics

Tesseract and pytesseract

Tesseract and pytesseract are also required. To install tesseract please visit: https://tesseract-ocr.github.io/tessdoc/Installation.html

Updating the package

To update the package via pip, you can use:

pip install --user --upgrade pyaesthetics

Example

pyaeshtetics modules can be used one at the time to estimate one specific feature, or they can be automatically called using an automated entrypoint that calls all the available modules at once.

Example 1: one single feature (e.g. Brigthness BT601)

#load only the neede functions from the specific module
from pyaesthetics.brightness import relativeLuminance_BT601, sRGB2RGB
import cv2 #to open and handle images

img = "/path/to/image/image.jpg" #path to a sample image

img = cv2.imread(img) #load the image
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) #convert to the RGB colorscheme
img = sRGB2RGB(img) #convert pixels to their linear RGB values
print(relativeLuminance_BT601(img)) #evaluate luminance on the BT601 standard

Example 2: Complete analysis

import pyaesthetics
img = "/path/to/image/image.jpg" #path to a sample image
results = pyaesthetics.analysis.analyzeImage(img, method="complete") #perform all the availabe analysis using standard parameters
print(results)

Or for a faster analysis:

import pyaesthetics
img = "/path/to/image/image.jpg" #path to a sample image
results = pyaesthetics.analysis.analyzeImage(img, method="fast") #perform a subset of the analysis using standard parameters.
print(results)

Documentation

You can check the full documentation here: https://prettywebsite.readthedocs.io/en/latest/

Requirements

  • numpy
  • scipy
  • matplotlib
  • pandas
  • opencv-python
  • imutils
  • pytesseract

Contacts

Feel free to contact me for questions, suggestions or to give me advice as well at: giulio.gabrieli@iit.it or giulio@duck.com

Scientific Publications that used pyaesthetic

  • Gabrieli, G., Bornstein, M. H., Setoh, P., & Esposito, G. (2022). Machine learning estimation of users’ implicit and explicit aesthetic judgments of web-pages. Behaviour & Information Technology, 1-11.
  • Bizzego, A., Gabrieli, G., Azhari, A., Lim, M., & Esposito, G. (2022). Dataset of parent-child hyperscanning functional near-infrared spectroscopy recordings. Scientific Data, 9(1), 625.
  • Cianfanelli, B., Esposito, A., Spataro, P., Santirocchi, A., Cestari, V., Rossi-Arnaud, C., & Costanzi, M. (2023). The binding of negative emotional stimuli with spatial information in working memory: A possible role for the episodic buffer. Frontiers in Neuroscience, 17, 445.
  • Music A., Maerten A., Wagemans J. (2023).Beautification of images by generative adversarial networks. Journal of Vision 2023;23(10):14.

Presentation

  • Gabrieli, G., Scapin, G., & Esposito, G. (2022). Pyaesthetic, a python package for empirical aesthetic analysis. XXVII Conference of the International Association of Empirical Aesthetics, Philadelphia, United States. https://giuliogabrieli.it/posters/iaea2022/

Sponsors

The project has been sponsored by Gitkraken.

Coffee?

Buy Me a Coffee at ko-fi.com

About

A python package to extract visual features about the aesthetic appearance from still images.

License:GNU General Public License v3.0


Languages

Language:Jupyter Notebook 81.6%Language:Python 18.4%