Enum JpegLsColorTransform
A reversible colour transform applied to RGB before coding, as HP's JPEG-LS software and CharLS write it in an APP8 "mrfx" segment. It usually makes colour photographs smaller.
public enum JpegLsColorTransform
Fields
Hp1 = 1HP1: red and blue are coded as their difference from green.
Hp2 = 2HP2: red as its difference from green, blue as its difference from the mean of red and green.
Hp3 = 3HP3: blue and red as differences from green, green with a quarter of their sum added.
None = 0No transform: the components are coded as they are.
Examples
// Near-lossless: every sample within 2 of the original, for a much smaller file. Restart markers every 64 lines let a
// damaged file be read again from the next one.
using (FileStream near = File.Create("duck-near.jls"))
{
duck.Save(near, JpegLsFormat.Info, new JpegLsWriterOptions { Near = 2, RestartInterval = 64 });
}
// Lossless with HP's colour transform, which shrinks most photographs further, sample-interleaved.
using (FileStream hp = File.Create("duck-hp1.jls"))
{
duck.Save(hp, JpegLsFormat.Info, new JpegLsWriterOptions { ColorTransform = JpegLsColorTransform.Hp1, Interleave = JpegLsInterleave.Sample });
}
// 12-bit samples from a 16-bit raster, as medical images often store them.
using Raster<Gray16> scan = duck.As<Gray16>();
using (FileStream twelve = File.Create("scan-12.jls"))
{
scan.Save(twelve, JpegLsFormat.Info, new JpegLsWriterOptions { BitsPerSample = 12 });
}