Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用MODI并将图像更改为灰度_C#_Image_Ocr_Modi - Fatal编程技术网

C# 使用MODI并将图像更改为灰度

C# 使用MODI并将图像更改为灰度,c#,image,ocr,modi,C#,Image,Ocr,Modi,我正在使用Microsoft Office Document Imaging(MODI)并尝试加载TIF 文件,但在执行OCR之前将其转换为灰度 我不知道该怎么做 我的代码中有: 私有修改文档_MODIDocument=null _MODIDocument=新的MODI.Document() _MODIDocument.Create(文件名); axMiDocView1.Document=\u MODIDocument 有人能告诉我如何将文档的图像部分转换为灰度吗 谢谢 然后删除组织图片 改变技

我正在使用Microsoft Office Document Imaging(MODI)并尝试加载TIF 文件,但在执行OCR之前将其转换为灰度

我不知道该怎么做

我的代码中有:

私有修改文档_MODIDocument=null

_MODIDocument=新的MODI.Document()

_MODIDocument.Create(文件名); axMiDocView1.Document=\u MODIDocument

有人能告诉我如何将文档的图像部分转换为灰度吗

谢谢


然后删除组织图片

改变技术。我们走了这条路,在Office中遇到了版本问题,在网络驱动器上遇到了损坏的文件,然后MS在Office 2010中停止了它。
public static Bitmap Grayscale(Bitmap bitmap)
{
    //Declare myBitmap as a new Bitmap with the same Width & Height
    Bitmap myBitmap = new Bitmap(bitmap.Width, bitmap.Height);

    for (int i = 0; i < bitmap.Width; i++)
    {
        for (int x = 0; x < bitmap.Height; x++)
        {
            //Get the Pixel 
            Color BitmapColor = bitmap.GetPixel(i, x);
            //I want to come back here at some point and understand, then change, the constants
            //Declare grayScale as the Grayscale Pixel
            int grayScale = (int)((BitmapColor.R * 0.3) + (BitmapColor.G * 0.59) + (BitmapColor.B * 0.11));

            //Declare myColor as a Grayscale Color
            Color myColor = Color.FromArgb(grayScale, grayScale, grayScale);

            //Set the Grayscale Pixel
            myBitmap.SetPixel(i, x, myColor);
        }
    }
    return myBitmap;
}
Bitmap oldBitmap = new Bitmap(Server.MapPath("~/Db/Plates/" + dosyaadi), false);
Bitmap newBitmap = Grayscale(new Bitmap(oldBitmap));
string name = "grayscale";
newBitmap.Save(Server.MapPath("~/Db/Plates/") + name + ".jpg", ImageFormat.Jpeg);