2013-06-27 96 views
0

有人可以帮助我读取和提取明智和明智的图像行信息?算法读取一行图像明智和列明智?

我的努力是从音乐壁中提取信息。

例五线谱图像:

Image

对于图像由具有几个板条线,我需要提取由板条数据破碎,顺序。

有人可以帮我一起代码片段吗?要使算法逐行提取?

回答

2

无论你做什么,来自图像的信息都被提取为“行/列明智”;请记住,图像是从其像素进行分析的,即小方块。它一个接一个地读取所有这些小方格。

图像处理的难点在于处理特定的几何问题。例如:从这行逐行读取一个复杂的形状,如链接中的一个五线谱。这个小代码(使用C#.NET编写)提供了一个简单版本的算法:它通过影响单个变量(readVertically)逐行或逐列读取。我想这是一个足够好的介绍来帮助你:

private void readImage(string imagePath) 
{ 
    Bitmap imageBitMap = (Bitmap)Bitmap.FromFile(imagePath); 

    bool readVertically = true; //This flag tells where the image will be analysed vertically (true) or horizontally (false) 

    int firstVarMax = imageBitMap.Width; //Max. X 
    int secondVarMax = imageBitMap.Height; //Max. Y 
    if (!readVertically) 
    { 
     firstVarMax = imageBitMap.Height; 
     secondVarMax = imageBitMap.Width; 
    } 

    for (int firstVar = 0; firstVar < firstVarMax; ++firstVar) 
    { 
     for (int secondVar = 0; secondVar < secondVarMax; ++secondVar) 
     { 
      //Color of the given pixel. Here you can do all the actions you wish (e.g., writing these pixels to other file) 
      if (readVertically) 
      { 
       Color pixelColor = imageBitMap.GetPixel(firstVar, secondVar); 
      } 
      else 
      { 
       Color pixelColor = imageBitMap.GetPixel(secondVar, firstVar); 
      } 
     } 
    } 
} 
+0

非常感谢你的代码。它帮助了很多 我设法通过添加以下内容来修改您的代码。 'byte pixel = pixelColor.B;' – hirosht

+1

我很高兴知道它已经帮助你开发出你想要的东西。 – varocarbas