1
필자는 각 프린지가 추가 처리를위한 얼룩으로 간주되는 얼룩말 줄무늬 이미지를 가지고 있지만 고려되어서는 안되는 얼룩이 포함되어 있습니다. AForge.NET/C#/VisualStudio2010을 사용하고 있습니다. 전형적인 예는 다음과 같다 :AFlobe.NET으로 BLOB를 수직으로 정렬하는 방법 BlobCounter?
계획이 작업을 수행하는 것입니다:
- 어떤 X가 수직 라인을 정의하는 좌표를 선택;
- 이 수직선을 가로 지르는 각 흰색 얼룩을 취합니다.
- 출력은 blob 또는 blob 인덱스의 목록이어야합니다. SORTED VERTICALLY (필수). 흰색 줄무늬가 높은 순서에서 낮은 순서로 정렬됩니다.
내가 성공적으로 참조 수직 라인을 넘어에만 변두리 분리이 코드를 가지고 :
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?)
}
}
의견을 보내 주셔서 감사합니다!
당신이 영역 또는 크기 또는 X 또는 Y로 모양을 얻을하는 방법을 chossing에 의해 수직으로 정렬 할 수 있습니다