Tint Using Lab
View as MarkdownTints using Lab color space.
Code Snippet
var color = new RgbColor(250, 178, 79);
var labColor = (LabColor)color.Convert(PixelFormat.Format24bppLab);
var a = labColor.A;
var b = labColor.B;
using (var lChannel = new Bitmap())
{
// Convert to Lab color space and get lightness channel
using (var reader = ImageReader.Create("Chicago.jpg"))
using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
using (var splitter = new LabChannelSplitter())
{
splitter.L = lChannel;
Pipeline.Run(reader + labConverter + splitter);
}
// Create a and b channels, combine with lightness channel and convert to RGB color space
using (var combiner = new LabChannelCombiner())
using (var aChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor((byte)(a + 127))))
using (var bChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor((byte)(b + 127))))
using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
using (var writer = ImageWriter.Create("TintUsingLab.jpg"))
{
combiner.L = lChannel;
combiner.A = aChannel;
combiner.B = bChannel;
rgbConverter.DestinationProfile = ColorProfile.FromSrgb();
Pipeline.Run(combiner + rgbConverter + writer);
}
}
Input
Chicago.jpg
Output
TintUsingLab.jpg
Used APIs
- Aurigma.GraphicsMill.Codecs.ImageReader
- Aurigma.GraphicsMill.Codecs.ImageReader.Create(String)
- Aurigma.GraphicsMill.Codecs.ImageWriter
- Aurigma.GraphicsMill.Codecs.ImageWriter.Create(String)
- Aurigma.GraphicsMill.Color.Convert(PixelFormat)
- Aurigma.GraphicsMill.ColorProfile
- Aurigma.GraphicsMill.ColorProfile.FromSrgb
- Aurigma.GraphicsMill.GrayscaleColor
- Aurigma.GraphicsMill.LabChannelCombiner
- Aurigma.GraphicsMill.LabChannelCombiner.A
- Aurigma.GraphicsMill.LabChannelCombiner.B
- Aurigma.GraphicsMill.LabChannelCombiner.L
- Aurigma.GraphicsMill.LabChannelSplitter
- Aurigma.GraphicsMill.LabChannelSplitter.L
- Aurigma.GraphicsMill.LabColor
- Aurigma.GraphicsMill.LabColor.A
- Aurigma.GraphicsMill.LabColor.B
- Aurigma.GraphicsMill.Transforms.ColorConverter
- Aurigma.GraphicsMill.Transforms.ColorConverter.DestinationProfile