---
title: "Tint Using Lab"
canonical: https://www.graphicsmill.com/samples/Transforms/Tint/TintUsingLab_cs
product: "Graphics Mill"
source: "Transforms/Tint/TintUsingLab.cs"
---

# Tint Using Lab

Tints using Lab color space.

## Instruction

Apply a tint to an image using Lab color space by manipulating the A and B channels, based on a specified color.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using ColorConverter = Aurigma.GraphicsMill.Transforms.ColorConverter;
```

## Code Snippet

```csharp
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);
    }
}
```

## Explanation

The code:

- Defines an RGB color (250, 178, 79) and converts it to Lab color space, extracting the A and B values.
- Reads an image from "Chicago.jpg" and converts it to Lab color space, extracting the lightness channel.
- Creates new A and B channels based on the Lab color (adjusting with the extracted values).
- Combines the L, A, and B channels, then converts back to RGB color space.
- Saves the result to "TintUsingLab.jpg".

## Tags

- [Channels](<https://www.graphicsmill.com/samples/tags/channels_md>): Reading and combining image channels
- [Color Conversion](<https://www.graphicsmill.com/samples/tags/color-conversion_md>): Converting colors between color spaces
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [Transform](<https://www.graphicsmill.com/samples/tags/transform_md>): Image transforms and effects

## Input

- [Chicago.jpg](<https://www.graphicsmill.com/samples/Transforms/compiled/Debug/Chicago_jpg>) (preview)

## Output

- [TintUsingLab.jpg](<https://www.graphicsmill.com/samples/Transforms/compiled/Debug/TintUsingLab_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.ImageReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.Create(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_ImageReader_Create_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageWriter.Create(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_ImageWriter_Create_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Color.Convert(PixelFormat)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Color_Convert_1_3e209c07.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_ColorProfile.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile.FromSrgb](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ColorProfile_FromSrgb.htm.md>)
- [Aurigma.GraphicsMill.GrayscaleColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_GrayscaleColor.htm.md>)
- [Aurigma.GraphicsMill.LabChannelCombiner](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_LabChannelCombiner.htm.md>)
- [Aurigma.GraphicsMill.LabChannelCombiner.A](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabChannelCombiner_A.htm.md>)
- [Aurigma.GraphicsMill.LabChannelCombiner.B](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabChannelCombiner_B.htm.md>)
- [Aurigma.GraphicsMill.LabChannelCombiner.L](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabChannelCombiner_L.htm.md>)
- [Aurigma.GraphicsMill.LabChannelSplitter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_LabChannelSplitter.htm.md>)
- [Aurigma.GraphicsMill.LabChannelSplitter.L](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabChannelSplitter_L.htm.md>)
- [Aurigma.GraphicsMill.LabColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_LabColor.htm.md>)
- [Aurigma.GraphicsMill.LabColor.A](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabColor_A.htm.md>)
- [Aurigma.GraphicsMill.LabColor.B](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabColor_B.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorConverter.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.DestinationProfile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_DestinationProfile.htm.md>)
