This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.
Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
wussow  
#1 Posted : Saturday, June 11, 2005 2:13:00 AM(UTC)
wussow

Rank: Member

Groups: Member
Joined: 6/11/2005(UTC)
Posts: 1

Hello everybody,

is there a possibilty to change only one special color (e.g. red tones) in one Selection of an image? For example to correct red eyes ...

Or is such a implementation planned?

greets,

André

Dmitry  
#2 Posted : Sunday, June 12, 2005 2:03:00 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

You have two different ways to change specified channel of bitmap. The first one is to apply ChannelBalance transformation, the following code snippet extends values of red channel of the specified bitmap region:

Code:
// Source bitmap
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:/Rgb24.jpg");
Aurigma.GraphicsMill.BitmapData bitmapData = bitmap.LockBits(100, 100, 100, 100);

try
{
	// Apply channel balance
	Aurigma.GraphicsMill.Transforms.ChannelBalance transform = new Aurigma.GraphicsMill.Transforms.ChannelBalance();
	transform.Levels = new float[] {0.0f, 0.0f, -0.5f};
	transform.ApplyTransform(bitmapData);
}
finally
{
	bitmap.UnlockBits(bitmapData);
}

// Save results
bitmap.Save(@"c:\1.jpg");

The second one is to manilulate channel values by hand. The following code snippet extends values of red channel of the specified bitmap region too:

Code:
// Source bitmap
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:/Rgb24.jpg");
Aurigma.GraphicsMill.BitmapData bitmapData = bitmap.LockBits(100, 100, 100, 100);

try
{
	// Increase values of the second channel
	unsafe
	{
		int stride = bitmapData.Stride;
		byte *values = (byte *)bitmapData.Scan0.ToPointer();

		for(int i = 0; i < bitmapData.Height; i++)
		{
			byte *scanline = values + i * stride;

			for(int j = 0; j < bitmapData.Width; j++)
			{
				int channel = scanline[2];

				channel += 127;
				if(channel > 255)
					channel = 255;

				scanline[2] = (byte)channel;

				scanline += bitmapData.BitsPerPixel / 8;
			}
		}
	}
}
finally
{
	bitmap.UnlockBits(bitmapData);
}

// Save result
bitmap.Save(@"c:\2.jpg");

By the way we have implemented plugin for Graphics Mill for .NET for red eye removal. If you are interested in this software, please, contact us by email sales@aurigma.com.

If you have some more questions, feel free to contact us.

Edited by user Friday, May 23, 2008 2:59:18 PM(UTC)  | Reason: Not specified

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.