Skip to main content

An interface to various graphical NTSC filters.

Project description

NTSC-py

build-status PackageVersion PythonVersion Stable Format License

ctypes interfaces to Blargg's NTSC filter libraries.

NES NTSC SNES NTSC SMS NTSC
NES NTSC SNES NTSC SMS NTSC

Installation

The preferred installation of ntsc-py is from pip:

pip install ntsc-py

Debian

Make sure you have the clang++ compiler installed:

sudo apt-get install clang

Windows

You'll need to install the Visual-Studio 17.0 tools for Windows installation. The Visual Studio Community package provides these tools for free.

Usage

Python API

NES NTSC

To use the NES NTSC filter, first create an instance:

from ntsc_py import NES_NTSC
ntsc = NES_NTSC()

The setup function can be used to configure the parameters of the filter. The same parameters of the setup function can be passed to the constructor on initialization of the filter. See the table below for a description of each of the parameters for the setup function

ntsc.setup(mode='composite', gamma=1, artifacts=2, sharpness=0.4, ...)
Parameter Stable Values Description
mode rgb, composite, svideo, monochrome Sets all parameters to a preset value.
hue [-1.0, 1.0] Controls the hue of the image in degrees [-180, 180].
saturation [-1.0, 1.0] Controls the saturation from monochrome to over-saturated.
contrast [-1.0, 1.0] Controls the contrast of the luminance in the image.
brightness [-1.0, 1.0] Controls the brightness from dark to bright.
sharpness [-1.0, 1.0] Controls edge / contrast enhancement and blurring effects.
gamma [-1.0, 1.0] Adjusts the linearity of the luminance quantizer.
resolution ? Controls the resolution of the image.
artifacts ? Controls influence of artifacts caused by color changes.
fringing ? Controls influence of fringing caused by brightness changes.
bleed ? Controls the amount of color bleed (color resolution reduction)
merge_fields [0, 1] If true, merges even and off fields to reduce flicker.

Images can be filtered by assigning them to the input buffer of the image in NES pixel format using the NES palette of 64 unique colors.

ntsc.nes_pixels[:] = np.random.uniform(0, 63, ntsc.nes_pixels.shape)

Alternatively, RGB images can be converted to the NES palette using a mean squared error fit.

from ntsc_py import rgb2nes, nes2rgb
ntsc.nes_pixels[:] = rgb2nes(np.random.uniform(0, 255, ntsc.nes_pixels.shape[:2] + (3, )))

Once nes_pixels has been updated with new pixel data, call process to filter the image and compute the RGB output in ntsc_pixels.

ntsc.filter()

SNES NTSC

Coming Soon!

SMS NTSC

Coming Soon!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ntsc-py, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size ntsc_py-0.2.1.tar.gz (55.4 kB) File type Source Python version None Upload date Hashes View
Filename, size ntsc_py-0.2.1-cp39-cp39-macosx_11_0_x86_64.whl (35.7 kB) File type Wheel Python version cp39 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page