C# - How to convert an Image into an 8-bit color Image?

倖福魔咒の 提交于 2019-12-02 06:15:12

Although I'm not sure how to do it with plain vanilla C# you can use the FreeImage Project libraries to convert images formats:

FreeImage is an Open Source library project for developers who would like to support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by today's multimedia applications. FreeImage is easy to use, fast, multithreading safe, compatible with all 32-bit versions of Windows, and cross-platform (works both with Linux and Mac OS X).

It's written in C++ but has good .NET wrappers you can use.

I already did it in one Pattern Recognition project. Searching some image processing and pattern recognition books you can find these solutions.

a) If you want to convert to greyscale you can find in general two solutions.

#1 Averaging RGB channels. - You can take 8-bit values for avery single channel and calculate pixel = ( R+G+B )/3

#2 Take only the Green component. It is best viewed.

b) If you want to convert to 8bit color representation you need to use a Color table. You can see a solution here http://www.codeproject.com/KB/graphics/Image_Bitdepth_Conversion.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!