Rank: Member
Groups: Guest
Joined: 6/4/2007(UTC) Posts: 4
|
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: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
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");
Edited by user 17 years ago
| Reason: Not specified |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 6/4/2007(UTC) Posts: 4
|
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: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
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.
|
|
|
|
|
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.