views:

496

answers:

3

i want to convert a 24 bit per pixcel(Rgb) int 8 bit per pixel tiff image is there any code to convert please share or tell me the algo in c sharp

+1  A: 

Do you mean how do you turn a RGB image into a greyscale one? A simple perceptually-based method is to transform it into YIQ colorspace and discard the chroma information. You can generate the luminance portion by this equation:

 l = (0.299*r) + (0.583*g) + (0.114*b)
tkerwin
+1  A: 

Here is a good tutorial with C# code:

http://www.switchonthecode.com/tutorials/csharp-tutorial-convert-a-color-image-to-grayscale

Disclaimer: I work at Atalasoft.

If you are interested in a commercial solution, you can do this with DotImage. The code to convert a single framed tiff is

AtalaImage img = new AtalaImage("file.tif");
img = img.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale);
img.Save("gray.tif", new TiffEncoder(), null);

If you have multipaged TIFFs, you just need to loop through them.

Lou Franco
+1  A: 

Assuming you mean you want to convert from a 24 bit colour image to an 8 bit colour image, then you'll need to look into dithering algorithms.

A very simple dithering algorithm is described on this page: http://wwwhome.cs.utwente.nl/~schooten/graphics/ It's not very high quality, but it's easy to understand as a first attempt.

After that, have a go at the Floyd-Steinberg dithering algorithm. http://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering

Coxy