All Projects → 0x09 → Resdet

0x09 / Resdet

Licence: lgpl-2.1
Detect source resolution of upscaled images

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Resdet

Image Similarity
计算图片之间的相似度
Stars: ✭ 292 (+52.88%)
Mutual labels:  image-processing, image-analysis
Pytorch Ssim
pytorch structural similarity (SSIM) loss
Stars: ✭ 1,058 (+453.93%)
Mutual labels:  image-processing, image-analysis
Bild
Image processing algorithms in pure Go
Stars: ✭ 3,431 (+1696.34%)
Mutual labels:  image-processing, signal-processing
Image Js
Image processing and manipulation in JavaScript
Stars: ✭ 241 (+26.18%)
Mutual labels:  image-processing, image-analysis
Sod
An Embedded Computer Vision & Machine Learning Library (CPU Optimized & IoT Capable)
Stars: ✭ 1,460 (+664.4%)
Mutual labels:  image-processing, image-analysis
Menyoki
Screen{shot,cast} and perform ImageOps on the command line 🌱 🏞️
Stars: ✭ 255 (+33.51%)
Mutual labels:  image-processing, image-analysis
Segment Open
Segment Source Distribution
Stars: ✭ 34 (-82.2%)
Mutual labels:  image-processing, image-analysis
computer-vision-notebooks
👁️ An authorial set of fundamental Python recipes on Computer Vision and Digital Image Processing.
Stars: ✭ 89 (-53.4%)
Mutual labels:  signal-processing, image-analysis
Blind image quality toolbox
Collection of Blind Image Quality Metrics in Matlab
Stars: ✭ 105 (-45.03%)
Mutual labels:  image-processing, image-analysis
Pixlab
PixLab Resources & Sample Set
Stars: ✭ 74 (-61.26%)
Mutual labels:  image-processing, image-analysis
Pyimsegm
Image segmentation - general superpixel segmentation & center detection & region growing
Stars: ✭ 213 (+11.52%)
Mutual labels:  image-processing, image-analysis
Imageprocessing
MicaSense RedEdge and Altum image processing tutorials
Stars: ✭ 139 (-27.23%)
Mutual labels:  image-processing, image-analysis
Simpleitk
SimpleITK: a layer built on top of the Insight Toolkit (ITK), intended to simplify and facilitate ITK's use in rapid prototyping, education and interpreted languages.
Stars: ✭ 458 (+139.79%)
Mutual labels:  image-processing, image-analysis
Pywt
PyWavelets - Wavelet Transforms in Python
Stars: ✭ 1,098 (+474.87%)
Mutual labels:  image-processing, signal-processing
Mindboggle
Automated anatomical brain label/shape analysis software (+ website)
Stars: ✭ 112 (-41.36%)
Mutual labels:  image-processing, image-analysis
Computer Vision Video Lectures
A curated list of free, high-quality, university-level courses with video lectures related to the field of Computer Vision.
Stars: ✭ 154 (-19.37%)
Mutual labels:  image-processing, signal-processing
Pycbc
Core package to analyze gravitational-wave data, find signals, and study their parameters. This package was used in the first direct detection of gravitational waves (GW150914), and is used in the ongoing analysis of LIGO/Virgo data.
Stars: ✭ 177 (-7.33%)
Mutual labels:  signal-processing
Ybimagebrowser
iOS image browser / iOS 图片浏览器 (支持视频)
Stars: ✭ 2,230 (+1067.54%)
Mutual labels:  image-processing
Tachyon
Faster than light image resizing service that runs on AWS. Super simple to set up, highly available and very performant.
Stars: ✭ 177 (-7.33%)
Mutual labels:  image-processing
Weibo Img Crypto
自动加密解密微博上传的图片
Stars: ✭ 176 (-7.85%)
Mutual labels:  image-processing

resdet - Detect source resolution of upscaled images.

Dependencies

resdet bundles KISS FFT as its FFT implementation (permissively licensed) but can use FFTW (GPL, potentially faster) if available.
Image loaders are available using any or all of libpng, libjpeg, mjpegtools (for yuv4mpeg), and MagickWand.

libresdet can be used completely standalone provided the client supplies the image data.

Building

The tools and supplied build scripts target a generic *nix environment with bash, pkg-config, GNU make, and a GCC compatible C compiler using an autotools-like build process:

./configure
make
make install

see configure --help for options

Examples

Resize an image with ImageMagick's convert command and detect it:

$ convert blue_marble_2012.png -resize 150% resized.png

$ resdet resized.png
given: 768x768
best guess: 512x512
all width        height
  512 (77.03%)     512 (76.38%)

Just test if an image has been upscaled:

$ resdet -v0 resized.png && echo upscaled
upscaled

See resdet -h for more options.

API

resdet can be used as a library by including resdet.h and linking with libresdet. To install the library, use make install-lib after building.
A pkg-config file is included; linker flags can be gotten via pkg-config --libs --static resdet
API documentation is available in the doc subdirectory.
Though the supplied build script is meant for Unix-likes, libresdet is written in standard C and should be usable on any platform with a C99 libc.

FAQ

This utility takes an image or frames of video which may have been upscaled and attempts to exactly identify the original resolution.

How?

Traditional resampling methods tend to manifest as an odd extension of a signal's frequency domain combined with a low-pass filter (where the shape of the filter differs among the various resampling methods). Conveniently the Discrete Cosine Transform causes the zero-crossings of this extension to fall at exactly the offset the source was upscaled from. resdet works by trying to identify these inversions.

Getting the best results

resdet works best on images that are as close to the source as possible. Filtering and compression artifacts can significantly harm the accuracy of this test. In general, clearer and more detailed images will fare better.

Video

For compressed video stills, the best results can be gotten by choosing a highly detailed keyframe with a low quantizer. Single-frame yuv4mpeg streams are preferred over png screenshots for videos with chroma subsampling as it preserves the separation of the chroma planes. Some ways to obtain a y4m frame:

FFmpeg/avconv: ffmpeg -i source -ss timestamp -vframes 1 -pix_fmt yuv420p image.y4m

mpv: mpv --start timestamp --frames 1 --vf format=yuv420p -o image.y4m source

Better results should be possible by analyzing multiple frames together. resdet supports this with both the mjpegtools (y4m) and MagickWand image loaders. To obtain multiple frames in the examples above, simply replace the argument to -vframes for FFmpeg or --frames for mpv with the desired number of frames. Note that currently frames will be read in bulk, so choose only a small section of the video to avoid consuming too much memory. This is not an inherent limitation, and will likely change.

JPEG

Moderate to heavily compressed JPEG sources tend to produce false positives at multiples of 1/8 the input resolution, generally with more appearing and in higher ranks as the quality decreases. resdet currently doesn't filter/penalize such results, although this can be mitigated somewhat by applying a deblocking filter to the image before analysis.

Deblocking example with FFmpeg: ffmpeg -i source.jpg -vf pp=ha/va image.png

Caveats

resdet works well on images resampled with traditional methods, but will not work with newer neural network-based resizers.

If you think something might be upsampled but you aren't getting a good result with resdet, install spec and have a look at an absolute value spectrum – it's usually possible to identify by sight. Our example earlier looks like this:

Upscaled Blue Marble spectrum

Note the solid black lines indicating zero-crossings 512px in from each dimension.

Can the same method work for downsampling?

There's no direct equivalent. Since downsampling loses information by definition it's likely not possible. Certain spectral features can appear as a result of typical downsampling operations, but the author is unaware of a way to reliably identify or exploit them in a meaningful way.

Source?

Looking at too many spectrograms.
Specifically, this project was born out of a yet-unpublished image deduplication framework, while attempting to identify whether duplicates were scaled versions of one another.
While some resources doing similar things via unspecified methods exist, I don't know of any comparable algorithm to resdet or publication describing something like it (but would be glad to read if they exist).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].