Skip to content

RomanVPX/resolution-suggester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

395 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ResolutionSuggester

Python application License: MIT Python 3.13

A powerful tool for evaluating texture quality loss during scaling. Essentially, it analyzes images by reducing their resolution and then increasing them back to the original size, after which it measures the difference between the original and processed images using various perceptual metrics.

๐Ÿš€ Features

  • Comprehensive Analysis: Analyze image quality at various resolutions using multiple metrics
  • Multiple Metrics: PSNR, SSIM, MS-SSIM, TDPR, and LPIPS support
  • Optimal Resolution Suggestion: Get recommendations for the best resolution based on quality thresholds
  • Interpolation Methods: Choose between Bilinear, Bicubic, and Mitchell-Netravali interpolations
  • Per-Channel Analysis: Examine quality metrics for individual RGB/RGBA channels
  • Visualization: Generate charts showing quality vs. resolution
  • ML-Powered: Fast quality estimation using machine learning models
  • Export Options: Save results to CSV and JSON formats
  • Multilingual: Supports English and Russian interfaces

๐Ÿ“‹ Requirements

  • Python 3.10+
  • NumPy, OpenCV, Pillow for image processing
  • PyTorch, torchmetrics, and LPIPS for perceptual and neural metrics
  • Matplotlib for visualization
  • Scikit-learn for ML features
  • GPU is optional; CPU execution is supported

๐Ÿ”ง Installation

From Source

git clone https://github.com/RomanVPX/ResolutionSuggester.git
cd ResolutionSuggester
pip install .

For development installation:

pip install -e ".[dev]"

๐Ÿ’ป Usage

ResolutionSuggester provides two command-line interfaces and two subcommands:

  • resolution_suggester {analyze, model} [options] PATHS - main command
  • res-suggest {analyze, model} [options] PATHS - shorthand alias

Interface language could be chosen if not detected automatically:

  • res-suggest analyze {analyze, model} --lang en [options] PATHS - force English as an interface language
  • res-suggest analyze {analyze, model} --lang ru [options] PATHS - force Russian as an interface language

Show Halp Message

# Show help on [analyze] subcommand
res-suggest analyze --help

# Show help on [model] subcommand
res-suggest model --help

Basic Usage

res-suggest analyze /path/to/image.png

Analyze Multiple Images

res-suggest analyze /path/to/textures/folder/

Select Quality Metric

# Choose from: psnr, ssim, ms_ssim, tdpr, lpips
res-suggest analyze image.png -m ssim

Choose LPIPS Neural Network

# Choose from: alex (default/balanced), vgg (memory-hungry), squeeze (fast)
res-suggest analyze image.png -m lpips --lpips-net vgg

Choose Interpolation Method

# Choose from: bilinear, bicubic, mitchell (default)
res-suggest analyze image.png -i bilinear

Per-Channel Analysis

res-suggest analyze image.png -c

Generate Visualization Chart

res-suggest analyze image.png --chart

Switch Theme for Charts

# Choose from: dark (default), light
res-suggest analyze image.png --chart --theme light

Export Results

res-suggest analyze image.png -o # .csv
res-suggest analyze image.png -j # .json

Use ML Model for Fast Estimation

res-suggest analyze image.png --ml

Set Minimum Analysis Size

# Default and minimum is 16
res-suggest analyze image.png --min-size 32

Control Parallel Processing

# Disable parallel processing
res-suggest analyze image.png --no-parallel

# Set specific number of threads
res-suggest analyze image.png -t 4

Save Generated Images

# Save downscaled images
res-suggest analyze image.png --save-im-down

# Save upscaled images after downscaling
res-suggest analyze image.png --save-im-up

# Save all generated images
res-suggest analyze image.png -s

Switch Language

# Choose from: en, ru, auto (default)
res-suggest analyze image.png --lang ru

๐Ÿ“Š Example Output

โ•ญโ”€โ”€โ”€โ”€โ”€ Analysis (MS_SSIM) โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ LevelLight-01_comp_light.exr โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Resolution โ”ƒ R    โ”ƒ G    โ”ƒ B    โ”ƒ A    โ”ƒ Min  โ”ƒ Quality         โ”ƒ Quality Bar     โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 1024x1024  โ”‚ 1.00 โ”‚ 1.00 โ”‚ 1.00 โ”‚ 1.00 โ”‚ 1.00 โ”‚ Original        โ”‚                 โ”‚
โ”‚ 512x512    โ”‚ 1.00 โ”‚ 1.00 โ”‚ 1.00 โ”‚ 0.99 โ”‚ 0.99 โ”‚ Excellent       โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ โ”‚
โ”‚ 256x256    โ”‚ 0.97 โ”‚ 0.98 โ”‚ 0.97 โ”‚ 0.96 โ”‚ 0.96 โ”‚ Very good       โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ โ”‚
โ”‚ 128x128    โ”‚ 0.91 โ”‚ 0.93 โ”‚ 0.90 โ”‚ 0.87 โ”‚ 0.87 โ”‚ Noticeable loss โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ โ”‚
โ”‚ 64x64      โ”‚ 0.82 โ”‚ 0.86 โ”‚ 0.80 โ”‚ 0.76 โ”‚ 0.76 โ”‚ Noticeable loss โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ โ”‚
โ”‚ 32x32      โ”‚ 0.75 โ”‚ 0.80 โ”‚ 0.71 โ”‚ 0.64 โ”‚ 0.64 โ”‚ Noticeable loss โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ โ”‚
โ”‚ 16x16      โ”‚ 0.73 โ”‚ 0.78 โ”‚ 0.67 โ”‚ 0.59 โ”‚ 0.59 โ”‚ Noticeable loss โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Advanced Features

Generate Dataset and Train ML Model

# Genarate dataset
res-suggest model --generate-dataset /path/to/training/images/

# Train ML model using generated dataset
res-suggest model --train-ml /path/to/training/images/

# Generate dataset and train ML model in one go
res-suggest model --generate-dataset --train-ml /path/to/training/images/

Compare Real and ML-Predicted Results

res-suggest analyze image.png --compare-ml

GPU Acceleration Control

# Disable GPU acceleration during analysis
res-suggest analyze image.png --no-gpu

# Disable GPU acceleration during dataset generation
res-suggest model --generate-dataset --no-gpu /path/to/training/images/

๐Ÿ”ง Supported File Formats

  • EXR (.exr)
  • TGA (.tga)
  • PNG (.png)
  • JPEG (.jpg, .jpeg)

๐Ÿค Contributing

Contributions are welcome! Please check out our Contributing Guide.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ฅ Authors

  • Roman Vishnyakov - Initial work - RomanVPX

About

A tool that evaluates texture quality loss by scaling images down and up, then measuring perceptual differences between original and processed images.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors