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.

Source Distribution

ntsc_py-0.2.0.tar.gz (53.6 kB view hashes)

Uploaded Source

Built Distribution

ntsc_py-0.2.0-cp39-cp39-macosx_11_0_x86_64.whl (32.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page