各フリンジがさらなる処理のためにブロブと見なされるゼブラ ストライプの画像がありますが、考慮すべきでないブロブも含まれています。AForge.NET / C# / VisualStudio2010 を使用しています。典型的な例は次のとおりです。
計画はこれを行うことです:
- 垂直線を定義する X 座標を選択します。
- この垂直線を横切る各白い塊を取ります。
- 出力は、垂直方向に並べ替えられた BLOB または BLOB インデックスのリスト (これが必要です) である必要があります。これにより、白いフリンジが高いものから低いものへと順序付けられます。
私はこのコードを持っています。これは、参照垂直線を横切るフリンジのみを正常に分離します:
using AForge.Imaging;
using AForge.Imaging.Filters;
Bitmap threshold_binary = gimme_threshold_image();
var blob_counter = new BlobCounter();
blob_counter.ProcessImage(threshold_binary);
var blobs = blob_counter.GetObjects(threshold_binary, true);
int midline_x_coord = threshold_binary.Width/2;
int counter = 1;
foreach (var blob in blobs)
{
// This saves an image for each blob (white fringe) which crosses the vertical reference line,
// but the fringes are not sorted vertically!
if (blob.Rectangle.X < midline_x_coord & (blob.Rectangle.X + blob.Rectangle.Width) > midline_x_coord) {
blob_counter.ExtractBlobsImage(threshold_grayscale, blob, true);
var blobimage = blob.Image.ToManagedImage();
blobimage.Save(String.Format("{0}singlefringes/{1}_singlefringe.png", base_input_dir, counter));
counter++;
}
}
上記のブロックは並べ替えられたフリンジを返さないため、別のアプローチは、正中線をピクセルごとに垂直にスキャンして、順序付けられたブロブを識別することですが、その方法を理解するのに苦労しています. 命題は次のようになります。
for (int y = 0; y < threshold_binary.Height; y++) {
if (threshold_binary.GetPixel(midline_x_coord, y)) {
// somehow create a List of blobs or blob indexes,
// but only if I can find out which blob
// this pixel is in (brute-force would be ugly, right?)
}
}
ご提案ありがとうございます。