Skip to content

Releases

PictureSharp 0.9.1

Choose a tag to compare

@art-ix art-ix released this 02 Nov 11:20

Frame-by-frame reading and writing for plugin formats

Format plugins can now supply a frame reader and a frame writer. Image.OpenFrameReaderAsync and
Image.CreateFrameWriter then work for their formats exactly as for GIF, PNG/APNG and WebP: frames are read forward
one at a time, Current is borrowed, limits and cancellation apply to every frame, and incomplete path output is
deleted. A long animation no longer has to be loaded whole with Image.Load.

using PictureSharp;

// With a plugin that implements IImageFormatModule.FrameDecoder, for example a future PictureSharp.Jxl.
await using ImageFrameReader reader = await Image.OpenFrameReaderAsync("animation.jxl");
await foreach (ImageFrame frame in reader.ReadFramesAsync())
{
    Console.WriteLine($"{frame.Duration.TotalMilliseconds} ms");
}

MaxPixels now limits one canvas in every frame reader, built-in formats included: a reader holds only a few
canvases however long the animation is, so summing all frames rejected long animations that fit in memory easily.
MaxFrames, MaxInputBytes and MaxMetadataBytes still apply to the whole sequence, and Image.Load still sums the
pixels of all frames. To cap a reader's total work, set MaxFrames.

The plugin change is additive. Plugins built for 0.9.0 keep working, and their formats still report
NotSupportedException from the frame reader and writer until they implement the new members.

For plugin authors

  • IImageFormatModule gains FrameDecoder and FrameEncoder, both with a default of null. A frame decoder requires
    Decoder, and a frame encoder requires Encoder, which still writes a sequence declared as a single frame.
  • New types in PictureSharp.Formats: IImageFormatFrameDecoder, ImageFrameSource, ImageFrameDecodeContext,
    IImageFormatFrameEncoder, ImageFrameSink and ImageFrameSequenceInfo.
  • The library keeps every cross-format check: frame size, pixel type, ownership, the declared frame count, MaxPixels
    for the canvas, MaxFrames, MaxInputBytes, FirstFrameOnly and error mapping. Truncated input
    (EndOfStreamException) is reported as ImageFormatException. Writers get options validation before the file is created, temporary files for
    sinks that need to seek, and 8-bit copies of frames the sink does not accept.
  • These types are new and not yet in the stable plugin SPI. They join it
    once a released plugin uses them. A plugin that implements them requires PictureSharp 0.9.1. Plugins that do not
    can keep 0.9.0 as their minimum.

See reading and writing frame by frame for an
example and the full contract.

Verification

The x64 Release suite passes: 9428 tests passed, 8 Windows-only tests skipped, including all reference-tool tests.
Package consumers pass full trimming and Native AOT checks for the core, a plugin frame reader and writer, and the
adapters. No SIMD code changed, so the 0.9.0 ARM64 results still apply.

PictureSharp 0.9.0

Choose a tag to compare

@art-ix art-ix released this 28 Oct 15:49

16-bit image editing

Edit and save 16-bit images without reducing them to 8 bits along the way. This works across all image
operations, from resizing and color correction to film negatives and HDR gain maps.

Requires .NET 10. This release changes the pixel API and plugin API. Applications using 0.8.5 need a few code
changes and updated plugins. Follow the migration guide.

Keep 16-bit precision

Loading still returns an 8-bit image by default. Set PreserveBitDepth = true to keep deeper source samples:

using PictureSharp;
using PictureSharp.Formats.Png;

using Image scan = Image.Load("scan.png", new DecoderOptions { PreserveBitDepth = true });
scan.Mutate(x => x.AutoContrast().Resize(1600, 0));
scan.SaveAsPng("edited.png", new PngEncoderOptions { BitDepth = PngBitDepth.Sixteen });

PNG supports 16-bit grayscale, RGB and alpha, including interlaced and animated files. Its output depth can be
chosen automatically or set to 8 or 16 bits. PNG sBIT metadata describes the source precision without changing
pixel values.

Other changes

  • Rgba64 stores 16-bit channels. Image.PixelType tells you whether an image uses Rgba32 or Rgba64.
    Direct pixel access now includes the pixel type, for example GetRowSpan<Rgba64>(y).
  • Levels, curves and sample thresholds use values from 0 to 1. Related members have Normalized in their names.
    Histograms can count all 65536 sample values in a 16-bit image.
  • Color conversion processes deeper inputs at 16-bit precision before reducing them, if requested.
    HDR tone mapping can also return a 16-bit image.
  • The Skia adapter supports integer 16-bit RGBA. System.Drawing output remains 8-bit per channel.
  • The command-line converter adds --depth auto|8|16; its default is still 8.
  • A 16-bit pixel counts twice against MaxPixels. GIF also checks oversized frame buffers before allocating them.

Built-in formats other than PNG save 8-bit output. For deeper output, use TIFF 0.7.4, HEIF 0.7.0 (10-bit HEVC)
or JPEG XL 0.7.8. These plugin versions require core 0.9.0; earlier builds are rejected when registered.
Formats.Extra is outside this update.

Verification

The x64 test suite passes with and without hardware acceleration: 9398 passed, 8 Windows-only tests skipped.
All 261 reference-tool tests pass. Package consumers pass full trimming and Native AOT checks for the core and adapters.

On ARM64, 9295 tests pass and the same 8 Windows-only tests are skipped, both with and without hardware acceleration.
All 138 SIMD comparisons pass. Large private 48 MP HDR tests were checked on x64 because they exceed the ARM device's
4 GiB test heap. Detailed results and comparison tolerances are in the verification record.

PictureSharp 0.8.5

Choose a tag to compare

@art-ix art-ix released this 26 Oct 21:18

Image.Identify now describes the colour layout of a file without decoding it: colour model, channels, sample type,
alpha mode, ICC presence and H.273 (CICP) colour description, plus whether it is lossless. To give ImageInfo one
member per fact, this release breaks the plugin SPI and ImageInfo despite the patch number: plugins need a new
build against 0.8.5, and older plugin builds are rejected at registration.

  • Colour description in Identify. ImageInfo.Color (ImageColorInfo) reports the model after the format's own
    colour transform (Gray, Rgb, Palette, Cmyk, Lab, Other, so a YCbCr JPEG is Rgb and a YCCK JPEG
    Cmyk), ChannelCount, BitsPerSample, SampleFormat (unsigned, signed, float), AlphaMode (None, Straight,
    Premultiplied), HasIccProfile and Cicp (CicpColorDescription, with IsHdrTransfer for PQ and HLG). Built-in
    formats read them from headers they already parse: PNG cICP, sRGB and iCCP, the BMP V4/V5 colour space and profile,
    the GIF ICC extension, JPEG and WebP ICC chunks. They are filled with IgnoreMetadata too and copy nothing, so they
    reserve no metadata (JPEG Identify keeps counting its ICC chunks, as before). Load does not apply CICP.

    ImageInfo info = Image.Identify("photo.png");
    if (info.Color.Cicp is { IsHdrTransfer: true })
    {
        Console.WriteLine($"HDR {info.Color.Model}, {info.Color.BitsPerSample}-bit");
    }
  • ImageInfo without duplicates or pretend defaults. Compression (Unknown, Lossless, Lossy, Mixed)
    replaces the WebP-only WebPCompression; Resolution is null when the file declares none instead of 96 DPI;
    FrameCount is null instead of 0 when only decoding could tell; the gain map members drop "Hdr", which next to PQ
    and HLG meant something else. BitsPerSample reports the stored depth, so it changes from 0.8.4's BitsPerChannel
    for GIF (index depth of the largest colour table), BMP (palette depth; widest mask, e.g. 6 for 5-6-5), ICO DIB entries
    (palette depth) and PCX palettes below 8 bits.

    0.8.4 0.8.5
    info.HasAlpha info.Color.HasAlpha (from Color.AlphaMode)
    info.BitsPerChannel info.Color.BitsPerSample
    info.WebPCompression, PictureSharp.Formats.WebP.WebPCompression info.Compression, ImageCompression
    info.HorizontalResolution, info.VerticalResolution info.Resolution?.Horizontal, .Vertical (null: not declared)
    info.FrameCount 0 info.FrameCount null
    info.Hdr, image.Hdr, HdrInfo info.GainMap, image.GainMap, GainMapInfo
    GainMapMetadata.ToHdrInfo(size) GainMapMetadata.ToGainMapInfo(size)

    ImageMetadata.HorizontalResolution/VerticalResolution and Image.HasAlpha are unchanged.

  • Plugins. ImageInfo.Color and Compression are required, so the compiler shows a plugin what to report. A
    plugin compiled against an older PictureSharp would fail inside Identify with MissingMethodException, so
    ImageConfigurationBuilder.AddFormat and ReplaceFormat now throw NotSupportedException naming the plugin and
    the version it was built against. Stable plugin SPI has the migration table and restates the
    promise from 0.8.5; Extending PictureSharp the rules for Identify.

  • CLI. info prints the colour description and the compression.

  • Plugin releases. PictureSharp.Tiff 0.7.3 is released together with this version. PictureSharp.Heif and
    PictureSharp.Formats.Extra follow in their own releases; until then, applications using them stay on 0.8.4, since
    0.8.5 rejects their current builds at registration.

Tests: a synthetic corpus in tests/assets/corpus/identify/ (67 files: every PNG colour type, cICP, sRGB and iCCP
combinations, JPEG Adobe, YCCK and incomplete ICC, WebP mixed animations, GIF table depths, BMP bitfields and V4/V5
colour spaces, ICO DIB depths, PCX planes) with expectations in identify_reference.json, cross-checked with Pillow.
Pixel results are unchanged.

PictureSharp 0.8.4

Choose a tag to compare

@art-ix art-ix released this 26 Oct 15:13

This release reduces the size of the NuGet packages.

  • Smaller package icon. The packages now include a 128×128 icon (12 KB), the size NuGet displays, instead of the 1254×1254 original (592 KB) added in 0.8.3. PictureSharp shrinks from 1.09 MB to 0.63 MB, and PictureSharp.Drawing, PictureSharp.Skia and PictureSharp.AspNetCore from about 0.49 MB to 26–35 KB.

No API, dependency or image-processing changes since 0.8.3.

PictureSharp 0.8.3

Choose a tag to compare

@art-ix art-ix released this 26 Oct 09:48

This release adds the PictureSharp project icon and updates the README presentation.

  • NuGet package icon. PictureSharp, PictureSharp.Drawing, PictureSharp.Skia and PictureSharp.AspNetCore now include the project icon.
  • README banner. A banner with the project logo, name and description replaces the small icon. A separate 1280×640 image is available for GitHub social previews.

No API, dependency or image-processing changes since 0.8.2.

PictureSharp 0.8.2

Choose a tag to compare

@art-ix art-ix released this 25 Oct 18:44

Three requests from the plugins: embedded images can no longer recurse without end, plugins keep metadata only they
understand, and the plugin SPI is declared stable until 2.0. No breaking API changes since 0.8.1; results for valid
files are unchanged.

  • Nesting limit for embedded images. Codecs for embedded images are chosen by signature, so a corrupt container
    could embed itself (a TIFF strip at offset 0, found by fuzzing the TIFF plugin) and decode itself again until the
    stack overflowed and the process ended. Images now nest at most 8 levels below the loaded file, through
    ImageDecodeContext.DecodeEmbedded, DecodeEmbeddedPart and the built-in containers (ICO, BMP with JPEG or PNG);
    a deeper one throws ImageFormatException naming the format that asked for it. The limit is fixed, not an option.
    See Limits and cancellation.

  • Format metadata. A plugin keeps data only its format understands, such as an XBM or cursor hotspot, in
    ImageMetadata as a record derived from PictureSharp.Formats.FormatMetadata, at most one per type:
    GetFormatMetadata<T>(), SetFormatMetadata(value), RemoveFormatMetadata<T>() and the read-only list
    FormatMetadata. Operations that move pixels (resize, crop, pad, rotate, flip, AutoOrient when it rotates,
    AutoCrop, a custom processor with another output size, DecoderOptions.TargetSize) remove the entries, since the
    library cannot adjust them; color and pixel operations keep them. IsEmpty, Clear() and Clone() include them,
    IgnoreMetadata is honoured by the plugin. See Metadata and
    Extending PictureSharp.

    public sealed record XbmMetadata((int X, int Y) Hotspot) : FormatMetadata;
    
    image.Metadata.SetFormatMetadata(new XbmMetadata((3, 1)));                      // in the decoder
    (int X, int Y)? hotspot = image.Metadata.GetFormatMetadata<XbmMetadata>()?.Hotspot; // in the encoder
  • Stable plugin SPI. From 0.8.2 the plugin contracts (IImageFormatModule, IImageFormatDecoder,
    IImageFormatEncoder<TOptions>, IImageFormatMetadataCodec, ImageDecodeContext, the gain map types and others)
    and the model plugins fill (Image, ImageFrame, Rgba32, ImageMetadata, DecoderOptions, EncoderOptions,
    ImageInfo) only grow until 2.0: interface members are added only with a default implementation and new parameters
    as overloads. A plugin can depend on PictureSharp 0.8.2 for its own 1.0. The list, the rules and the minimum-version
    policy are in Stable plugin SPI; tests/assets/PluginSpi.approved.txt and
    PluginSpiSnapshotTests enforce them. The earlier note that optional parameters were additive is corrected: they
    break compiled plugins.

Checked with the plugins on a local 0.8.2 package: PictureSharp.Tiff 3878/3878 tests and PictureSharp.Heif build
unchanged; PictureSharp.Formats.Extra keeps the XBM hotspot from load to save through FormatMetadata.

Verification (linux-x64): Release build without warnings; 7652 tests passed, 7 skipped (GDI+). No ARM64 run; the
changes contain no platform-specific code.

PictureSharp 0.8.1

Choose a tag to compare

@art-ix art-ix released this 23 Oct 12:40

HDR images can be written: hdr.ToGainMapImage() computes an ISO 21496-1 gain map from an HdrImage, so HDR pixels
save as an Ultra HDR JPEG, and Apple-only gain maps are now written as ISO 21496-1. No breaking API changes since
0.8.0; files written from ISO sources are byte for byte the same.

  • hdr.ToGainMapImage(options) returns an SDR image (the base, hdr.ToneMap(options.ToneMapping)) with an
    attached gain map computed as libultrahdr 2.0.2's generateGainMap computes it with its best-quality defaults:
    box-averaged samples, the log2 gain of HDR over SDR, bounds from the image's own gain range and an affine mapping to
    8-bit codes. The result carries the map like a loaded image, so ToHdr, geometric Mutate operations,
    GetGainMap() and JPEG with JpegGainMapMode.Require work as before. hdr.ToGainMapImage(sdrBase, options)
    uses a base of your own (same size, one frame, sRGB or Display P3 by its color description).

    using HdrImage hdr = photo.ToHdr();
    using Image sdr = hdr.ToGainMapImage(new GainMapOptions { ToneMapping = new ToneMappingOptions { Exposure = -0.3f } });
    sdr.SaveAsJpeg("regraded.jpeg", new JpegEncoderOptions { Quality = 95, GainMap = JpegGainMapMode.Require });
  • GainMapOptions (namespace PictureSharp.Processing): Scale (1–128, default 1), ChannelCount (3 or 1,
    default 3), Gamma (default 1), Headroom (default hdr.Headroom), ToneMapping and MaxDegreeOfParallelism.
    The defaults are libultrahdr's API defaults. When the HDR image is Display P3 and the base sRGB, the gain is applied
    in Display P3 and the map carries a Display P3 ICC profile, as libultrahdr writes it.

  • new HdrImage(width, height, pixels, colorSpace, headroom, metadata) creates an HdrImage from a copy of
    linear Rgba128 pixels, for example from a plugin decoding a floating-point format. headroom defaults to the
    largest component; GainMapKind is None.

  • Apple → ISO 21496-1: JpegGainMapMode.Preserve and Require now write a map described by Apple metadata only,
    and GetGainMap() returns it, as ISO 21496-1: gain bounds 0 and log2 H, gamma 1, no offsets, one channel, with the
    map codes recomputed so that the full-headroom rendition matches Apple's formula on the ISO sampling grid. Before,
    Preserve wrote SDR, Require and GetGainMap(require: true) threw NotSupportedException and GetGainMap()
    returned null. GainMapMetadata.ToIso() on Apple metadata still throws, since the codes must change too. The CLI's
    -hdr keep accepts Apple-only files.

See HDR files from HDR pixels
and Floating-point HDR sources.

The adapter packages are released at the same version without changes.

Validation (budget agreed before the implementation, generator in tests/assets/hdr_reference.json):

  • Against libultrahdr 2.0.2's generateGainMap on identical inputs (a new harness,
    tests/assets/ultrahdr_generate_oracle.cpp; synthetic and corpus HDR images, sRGB and Display P3, scales 1–4, one
    and three channels): map codes and ISO 21496-1 payloads are identical. The one deliberate difference: with gamma ≠ 1,
    gains below the clamped minimum give code 0, where libultrahdr computes pow of a negative number.
  • Round trip HdrImage → JPEG (base quality 95 4:4:4, map 95) → ToHdr: on a smooth synthetic image a median error
    of 0.8% and p99 7% (map alone 0.2% / 0.7%); on iPhone photos 2.8% (sRGB) and 4.2% (Display P3) median. In every case
    at or below the same inputs encoded by libultrahdr's ultrahdr_app. Generated files decode in ultrahdr_app within
    the 0.6.5 pipeline budget.
  • Apple → ISO at full headroom with the source's base pixels: median 0.2–0.5% and p99 4.5–10.6% on iPhone photos with
    the ISO segments hidden; median 0.6% and p99 10% on the 48×32 synthetic corpus. The written files decode in
    ultrahdr_app within the pipeline budget.
  • All tests passed on linux-x64, including the oracle, slow and local tests, trimming and Native AOT (the smoke test
    generates a map and writes it to JPEG).
  • No SIMD code was added; not run on ARM64.

PictureSharp 0.8.0

Choose a tag to compare

@art-ix art-ix released this 23 Oct 10:05

Format plugins can write HDR gain maps: an encoder reads the map attached to the image, and the JPEG encoder now also
writes maps that a plugin attached, so an HEIC photo loaded through a plugin can be saved as an Ultra HDR JPEG. No
breaking API changes since 0.7.13; files written from JPEG sources are byte for byte the same.

  • image.GetGainMap() (namespace PictureSharp.Formats) returns the map an encoder writes as an
    EncodableGainMap: its GainMapMetadata and a GainMapImage in the size and orientation of the image's current
    pixels, after ApplyExifOrientation and geometric edits. When the map was attached by a plugin and the image was
    neither rotated nor edited, Map is the plugin's own instance, so the plugin can copy its compressed data instead of
    encoding it again. GetGainMap() decodes nothing; Map.Decode returns a new image on every call.
    require: true throws what JpegGainMapMode.Require throws; otherwise a missing, Apple-only or unusable map gives
    null.

    if (image.GetGainMap(require: options.GainMap == MyGainMapMode.Require) is { } gainMap)
    {
        byte[] iso = gainMap.Metadata.ToIso();
        using Image map = gainMap.Map.Decode(maxDegreeOfParallelism: -1, cancellationToken);
    }
  • GainMapMetadata.ToIso() writes ISO 21496-1 metadata, the input of ParseIso: the payload of a JPEG APP2
    segment or a HEIF tmap item. Values are stored as the fractions libultrahdr 2.0.2 chooses (a port of
    encodeGainmapMetadata and its continued fractions), one channel when all channels are equal.
    GainMapMetadata.MultiplicationSpace gives the primaries the gain is applied in when they are not the base
    image's; the payload only flags them, so a writer stores them with the map. GainMapMetadata.ToAlternateIcc()
    writes them as the ICC profile ParseIso reads back (null when the base primaries apply).

  • JPEG with a plugin's map: JpegGainMapMode.Preserve and Require write a map attached by a format plugin like
    an edited map (GainMapQuality, gray maps as grayscale, RGB maps 4:4:4) with metadata from ToIso(). Before, they
    wrote SDR or threw NotSupportedException. When the gain is applied in primaries other than the base image's, the
    map gets the ICC profile libultrahdr writes for sRGB or Display P3. Maps loaded from JPEG are still copied with
    their original metadata.

See Writing gain maps in a plugin
and HDR.

The adapter packages are released at the same version without changes.

Validation:

  • Against libultrahdr 2.0.2 (a new harness, tests/assets/ultrahdr_iso_oracle.cpp): the fractions of about 16,000
    values and the ISO payloads of more than 500 metadata sets (corpus and random, one and three channels, both
    layouts) and the sRGB and Display P3 map profiles are byte for byte identical. ParseIso(ToIso(m)) gives the same
    values for every ISO file of the corpus.
  • JPEG files written from plugin maps decode in ultrahdr_app within the 0.6.5 pipeline budget; reloaded, their
    metadata is exact and the map within 8 codes of the attached one (JPEG quality 95, the 0.6.9 budget for edited
    maps).
  • A test plugin writes maps through GetGainMap: JPEG to plugin and plugin to plugin round trips, unedited plugin
    maps copied byte for byte, oriented and edited maps in the geometry of the base pixels.
  • 75 JPEG files written with Preserve from the HDR corpus (unedited, oriented, edited) are byte for byte those of
    0.7.13.
  • All tests passed on linux-x64, including the oracle and slow tests, trimming and Native AOT (the smoke test reads a
    plugin's map with GetGainMap and writes it to JPEG).
  • No SIMD code was added; not run on ARM64.

PictureSharp 0.7.13

Choose a tag to compare

@art-ix art-ix released this 22 Oct 17:04

Film negatives without manual regions: DevelopNegative() finds the frame in a photographed 35 mm strip, straightens
and crops it, takes the film base from the rebate and evens out the backlight. No breaking API changes since 0.7.12;
existing operations produce exactly the same pixels, except DevelopNegative() on a photograph with perforation (see
below).

  • FindFilmFrame() finds the frame nearest the photograph's center from its perforation, which must show the
    backlight. It returns a FilmFrame: Angle straightens the strip, Bounds is the picture in the image rotated by
    that angle, PerforationsVertical tells the strip's direction and CutEdges lists the edges the photograph cuts
    off. It works on a preview of about 1024 pixels: 37 ms for 11 MP on 8 threads. Without perforation it returns
    null.

    if (image.FindFilmFrame() is { } frame) image.Mutate(x => x.Rotate(frame.Angle).Crop(frame.Bounds));
  • DevelopNegative() is fully automatic: it finds the frame, measures it with the rebate beside the perforation
    as the film base, straightens and crops it in one bicubic pass (exactly Rotate(Angle).Crop(Bounds)), and divides
    the film base by the backlight's gradient measured on the rebate. 140 ms for an 11 MP strip on 8 threads.

    image.Mutate(x => x.DevelopNegative());
    NegativeAnalysis analysis = image.AnalyzeNegative();   // the same measurement, with analysis.Frame
    image.Mutate(x => x.DevelopNegative(new NegativeOptions { Frame = analysis.Frame, Calibration = analysis.Calibration }));

    New options: Frame (a frame found before), Crop (default true) and CorrectIllumination (default true).
    Setting Region or FilmBaseRegion turns the search off and develops the whole image, as in 0.7.12. A photograph
    without perforation (a frame that is already cropped, 120 film) is developed whole, as before.

    Behavior change: on a photograph with perforation, DevelopNegative() now returns the cropped frame, where
    0.7.12 returned the whole photograph with the rebate and light box inverted. Set Crop = false to keep the size.

  • New warnings and measurements: NegativeAnalysis.Frame and FilmBaseUniformity (the texture of the backlight
    through the rebate). BacklightTexture reports a monitor's pixel grid showing through the film, FrameCut a frame
    cut off by the photograph, and UnevenIllumination a backlight more than 25% brighter at one corner of the frame
    than at another. FilmBaseEstimated now appears only when neither a region nor a rebate gave the base.

  • Faster bicubic rotation: the bicubic filter of Rotate(degrees) evaluates the four channels in one
    Vector256<double> with the same operations, and its rows run in parallel: identical pixels, 2× faster on one
    thread.

See Film negatives and
Film frames (0.7.13).

The adapter packages are released at the same version without changes.

Validation:

  • All tests passed on linux-x64, including the oracle and slow tests, trimming and Native AOT (the smoke test finds
    and develops a strip).
  • Synthetic strips: straight, turned by −1.3° to 6°, vertical, cut off on each side and lit unevenly; the frame is
    found inside its picture and covering at least 95% of it, with no rebate in the crop, the angle within 0.1°, and the straightened crop equals
    Rotate(Angle).Crop(Bounds) pixel for pixel. Results are identical on 1 and 8 threads.
  • Local tests on 15 private iPhone photographs of a Kodak Gold strip on a light box and a monitor: all 14 frames with
    perforation are found as checked by eye, including close-ups whose frame the photograph cuts; the monitor
    photographs report BacklightTexture, and a cropped frame and scans without perforation give no frame.
  • The vector bicubic filter equals the scalar one on random images and angles.
  • Not run on ARM64. The vector filter needs Vector256 and otherwise falls back to the scalar code.

PictureSharp 0.7.12

Choose a tag to compare

@art-ix art-ix released this 22 Oct 15:53

A fix to the dust removal of 0.7.11, which was tagged but not published to NuGet. This release contains everything
described in 0.7.11: AnalyzeNegative, DevelopNegative, InvertNegative,
NegativeCalibration, Curves, WhiteBalance(Rgba32), AutoWhiteBalance, RemoveDust and ReduceColorNoise. No
breaking API changes since 0.7.10; existing operations produce exactly the same pixels.

  • RemoveDust keeps detail larger than a speck: in 0.7.11 it erased the slanted letters of a licence plate. A
    speck is a pixel that stands out from the median of four segments through it (horizontal, vertical and both
    diagonals), and a stroke slanted between those directions stands out from all four. Now each connected group of
    such pixels is removed only when it spans at most size + 2 pixels and nothing around it continues it: no
    neighbouring pixel differs from its surroundings in the same direction by more than half as much as the speck. The
    1-pixel ring around a removed speck is replaced too, so no outline of its soft rim stays.

    Photograph size Before 0.7.12
    Licence plate on a phone photo of a negative 11 29% of the letters' bright pixels stay all stay
    Licence plate on a 22 MP scan 19 stroke ends cut unchanged
    Dust on a black-and-white negative 10 removed, with a visible ring removed, no ring

    Isolated detail no larger than size, such as a catchlight, a small letter or the hole of a small 0, is still
    taken for dust: keep size near the size of the dust.

  • Dust removal is off by default in DevelopNegative: NegativeOptions.DustSize defaults to 0 instead of
    null. DustSize = null still selects the automatic size (0.5% of the shorter side).

    image.Mutate(x => x.DevelopNegative());                                     // no dust removal
    image.Mutate(x => x.DevelopNegative(new NegativeOptions { DustSize = 4 })); // specks up to 4 pixels

    See Dust and color noise and
    Film negatives.

RemoveDust(6) on 12 MP takes 0.44 s on 8 threads (0.41 s in 0.7.11); DevelopNegative without dust removal takes
about 0.22 s on an 8 MP photographed negative.

The adapter packages are released at the same version without changes.

Validation:

  • All tests passed on linux-x64, including the oracle and slow tests, trimming and Native AOT.
  • RemoveDust matches the numpy reference bit for bit, including a new image with lettering and a slanted bar.
  • Synthetic lettering with rings, bars and a bar slanted by 20° keeps every stroke pixel at sizes 4, 8 and 11 while
    its specks go; 0.7.11 kept 1361 and 325 of 1827.
  • Local tests on private photographed negatives and scans: the plate test above, and dust removed on a
    black-and-white negative.
  • A timing-sensitive cancellation test, which stopped the NuGet publication of 0.7.11, now measures a warmed-up run.
  • Not run on ARM64. The change adds no platform-specific code.