Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
edorn  
#1 Posted : Monday, June 04, 2007 11:45:53 PM(UTC)
edorn

Rank: Member

Groups: Member
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
Alex Kon  
#2 Posted : Tuesday, June 05, 2007 1:05:30 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
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

edorn  
#3 Posted : Tuesday, July 24, 2007 5:07:08 AM(UTC)
edorn

Rank: Member

Groups: Member
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
Alex Kon  
#4 Posted : Sunday, July 29, 2007 6:33:45 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
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.
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.