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://Loading original bitmap.
Aurigma.GraphicsMill.Bitmap bmp = new Aurigma.GraphicsMill.Bitmap(@"y:\venezia_01s.bmp");
//Converting to 8bppGrayscale to discard color information as we don't need it
bmp.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format8bppGrayScale);
//Building look up table (LUT) for our grayscale image. It specifies black (0) result value for all
//pixels in the range [0, 254]. And pure white pixels (255) remain white.
Aurigma.GraphicsMill.Transforms.Lut nonWhiteToBlackLut = new Aurigma.GraphicsMill.Transforms.Lut(false);
for (int i = 0; i <= 254; i++)
nonWhiteToBlackLut[i] = 0;
nonWhiteToBlackLut[255] = 255;
//Applying LUT to obtain the desired result. After that you can do what you want
//with this image - save it, convert to 24bpp RGB or convert to 1bpp bitmap,
//according to your task.
bmp.ColorAdjustment.ApplyLut(nonWhiteToBlackLut);
bmp.Save(@"y:/whiteAndBlackResult.bmp");
Edited by user Monday, December 17, 2007 7:37:16 PM(UTC)
| 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.