<commit_before>resdet - Detect source resolution of upscaled images.

# Dependencies

Requires [FFTW](http://fftw.org).  
Image readers are available using libpng, libjpeg, mjpegtools (yuv4mpeg), and/or MagickWand, but these aren't required.

# Building

    ./configure
	make
	make install

see `configure --help` for options

# Examples

Resize an image with [ImageMagick](http://www.imagemagick.org)'s `convert` command and detect it:

    $ convert Lenna.png -resize 200% resized.png

    $ resdet resized.png
	given: 1024x1024
	best guess: 512x512
	all width        height
	  512 (68.03%)     512 (67.83%)

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](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](doc) subdirectory.

# FAQ
This utility takes an image or frame 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.<commit_msg>doc: Use smaller example image.<commit_after>resdet - Detect source resolution of upscaled images.

# Dependencies

Requires [FFTW](http://fftw.org).  
Image readers are available using libpng, libjpeg, mjpegtools (yuv4mpeg), and/or MagickWand, but these aren't required.

# Building

    ./configure
	make
	make install

see `configure --help` for options

# Examples

Resize an image with [ImageMagick](http://www.imagemagick.org)'s `convert` command and detect it:

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

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

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](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](doc) subdirectory.

# FAQ
This utility takes an image or frame 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.
{'fraction_non_alphanumeric': 0.061385099685204614, 'fraction_numerical': 0.016789087093389297, 'mean_word_length': 3.9778067885117494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6104595', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1026, 'n_words': 519}