Leo 發問時間: 電腦與網際網路程式設計 · 8 年前

c# 影像處理求方法

ex: 第一張是一個天空的圖 第二張是有鳥在天上飛

然後輸出的影像是那些鳥 我要如何計算有幾隻鳥?

我已經可以去背輸出主體 但是我想要計算有幾隻鳥

我只知道大概是用顏色去分 但我不知道如何把每隻鳥區分出來

也希望可以貼一些相關網站給我

3 個解答

評分
  • 最佳解答

    一般使用C#的人,會採用

    SetPixel的方法,程式碼如下:

    Bitmap source = new Bitmap(3000, 2000, PixelFormat.Format32bppArgb);for (int h = 0; h < source.Height; h++){ for (int w = 0; w < source.Width; w++) { source.SetPixel(w, h, Color.White); }}

    Image img = new Image(3000, 2000);for (int h = 0; h < img.Height; h++){ for (int w = 0; w < img.Width; w++) { img[h, w] = new Bgr(255, 255, 255); }}

    Imageimg = new Image(3000, 2000);Parallel.For(0, img.Height, h =>{ Parallel.For(0, img.Width, w => { img[h, w] = new Bgr(255, 255, 255); });});

    Bitmap source = new Bitmap(3000, 2000, PixelFormat.Format32bppArgb);MemoryStream memoryStream = new MemoryStream();source.Save(memoryStream, ImageFormat.Bmp);byte[] byteArray = memoryStream.ToArray();int totalPixels = source.Height * source.Width;for (int p = 0; p < totalPixels; p++){ byteArray[54 + p] = 255; } memoryStream = new MemoryStream(byteArray); source = new Bitmap(memoryStream);

    Bitmap source = new Bitmap(3000, 2000,PixelFormat.Format32bppArgb);BitmapData sourceData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);IntPtr source_scan = sourceData.Scan0;unsafe{ byte* source_p = (byte*)source_scan.ToPointer(); for (int height = 0; height < source.Height; ++height) { for (int width = 0; width < sourceData.Width; ++width) { source_p[0] = 255; //A source_p++; source_p[0] = 255; //R source_p++; source_p[0] = 155; //G source_p++; source_p[0] = 55; //B source_p++; } }}source.UnlockBits(sourceData);

  • ?
    Lv 7
    8 年前

    先跑一遍 canny,然後找 contour?

  • Chen
    Lv 6
    8 年前

    You want to find object without relation to colors and angle and intensity and size in picture.

    If you want to learn image recognition, You must learn image segement( GABOR filter, CANNY, SIFT, SURF), and machine learning(PCA, ISOMAP, LLE , SVM ...etc), Maye you spend some hours in studying above statement.

    below some pictures are tested by my coding program(c/c++) without any graphic library( GDI, OPENCV, DIRECTX ...etc)

    test1: how to find one dime in coins. program finds result.

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013040819...

    one dime coins

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013040819...

    test2: how to find car plate in the picture(car02.jpg)

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013051415...

    test result:

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013051415...

    test3: how to find to recognite the people(picture1) in the picture(picture2)

    picture1

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013051415...

    picture2

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013051415...

    test result:

    圖片參考:http://imgcld.yimg.com/8/n/AC08187637/o/2013051415...

還有問題?馬上發問,尋求解答。