如何提取灰度图像的位面? [英] How Can I Extract Bitplanes Of A Gray Image?

查看:109
本文介绍了如何提取灰度图像的位面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。我怎样才能提取灰度图像的位平面?

i想从某个地方读取灰色图片,所以:

a)用双翼飞机1显示它

b)用双翼飞机1和2显示它>
c)用双翼飞机1和2和3显示它

d)用双翼飞机1和2和3和4显示它



i应该启用重做和撤消操作



请帮助

hi there. how can i extract bitplanes of a gray image?
i wanna read a gray picture from some place and so :
a) show it with biplane1
b)show it with biplane1 and 2
c)show it with biplane1 and 2 and 3
d)show it with biplane1 and 2 and 3 and 4

i should enable the "redo" and "undo" actions

please help

推荐答案

我也在努力按照您的要求完成,但让我们从任何支持的图像格式文件(JPG,BMP,PNG,GIF和TIFF)的简单灰度显示开始

I am also struggling to follow exactly what you want but lets start with a simple grayscale display of any supported image format file (JPG,BMP, PNG, GIF & TIFF)
public static Bitmap MakeGrayscale(Image original)
{
    //create a blank bitmap the same size as original image
    Bitmap newBitmap = new Bitmap(original.Width, original.Height);

    //get a graphics object from the new image
    Graphics g = Graphics.FromImage(newBitmap);

    //create the grayscale ColorMatrix
    ColorMatrix colorMatrix = new ColorMatrix(
        new float[][] 
{
    new float[] {.3f, .3f, .3f, 0, 0},
    new float[] {.59f, .59f, .59f, 0, 0},
    new float[] {.11f, .11f, .11f, 0, 0},
    new float[] {0, 0, 0, 1, 0},
    new float[] {0, 0, 0, 0, 1}
});

    //create some image attributes
    ImageAttributes attributes = new ImageAttributes();

    //set the color matrix attribute
    attributes.SetColorMatrix(colorMatrix);

    //draw the original image on the new image
    //using the grayscale color matrix
    g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
        0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);

    //dispose the Graphics object
    g.Dispose();
    return newBitmap;
}



来自带有按钮的简单表格的示例通话看起来像


A sample call from say a simple form with a a button would look like

private void button1_Click(object sender, EventArgs e)
{
    //get a graphics object
    Graphics graph = CreateGraphics();

    // load you bitmap image  =>  change the name Image.jpg below to your image
    // Don't forget full path if file isn't in exe directory
    // the function supports  BMP, JPG, PNG, TIFF or GIF formats
    Image img = Image.FromFile("Image.jpg"); 

    // Makes a greyscale version of the bitmap by calling above function
    Bitmap b = MakeGrayscale(img);
    
    // draw bitmap to 0,0 on form
    graph.DrawImage(b, 0, 0);
}





希望有帮助作为开始



Hope that helps as a start


这篇关于如何提取灰度图像的位面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆