|
|
Rank: Member Groups: Member
Joined: 6/5/2007 Posts: 4 Points: 0
|
Is there a way to convert an image so that every single pixel that is not white gets converted to black, irrelevant of the pixel being yellow, blue, etc?
We are using Graphics Mill 4.0
Thanks!
Edgar
|
|
Rank: Advanced Member Groups: Administration
, Member
Joined: 1/31/2005 Posts: 386 Points: 403
|
Hello Edgar, Yes, there are even several ways to do this. The easiest way to made all pixels black except pure white ones (R=255, G=255, B=255) is to use look up table (LUT) for that. Here is small code sample, which illustrates the way: Code:
Aurigma.GraphicsMill.Bitmap bmp = new Aurigma.GraphicsMill.Bitmap(@"y:\venezia_01s.bmp");
bmp.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format8bppGrayScale);
Aurigma.GraphicsMill.Transforms.Lut nonWhiteToBlackLut = new Aurigma.GraphicsMill.Transforms.Lut(false);
for (int i = 0; i <= 254; i++)
nonWhiteToBlackLut[i] = 0;
nonWhiteToBlackLut[255] = 255;
bmp.ColorAdjustment.ApplyLut(nonWhiteToBlackLut);
bmp.Save(@"y:/whiteAndBlackResult.bmp");
Best wishes, Alex.
|
|
Rank: Member Groups: Member
Joined: 6/5/2007 Posts: 4 Points: 0
|
Hi Alex,
Thanks for the code. I do have one more question. Is there a way now to convert all the black pixels to a different color. IE, after the image has been converted to monochrome/black and white, how do I go about converting all of the black pixels to another color, such as red?
Thanks!
Edgar
|
|
Rank: Advanced Member Groups: Administration
, Member
Joined: 1/31/2005 Posts: 386 Points: 403
|
Hello Edgar,
Hm... The simplest way to do this is to change corresponding colormap entry if you work with indexed bitmaps (maybe it will be effective for your task to convert your bitmaps to indexed pixel format). Another way is to iterate all pixels manually and transform colors if necessary.
Best wishes, Alex.
|
|
|
Guest |