// get segment by indext. have to run after extraction public CSegment GetSegmentByIndex(int nIndex) { if (listFull.Count >= nIndex) { CSegment seg = listFull.ElementAt(nIndex); return(seg); } return(new CSegment()); }
// Remove Rest Rectangle which occurs on the border. public void Remove_BoundingRect() { List <CSegment> listBuff = new List <CSegment>(); for (int i = 0; i < listFull.Count(); i++) { CSegment seg = listFull.ElementAt(i); Rectangle rc = seg.RC; if (CRect.IsBoarderPosition(rc, mapW - 1, mapH - 1) == false) { listBuff.Add(seg); } } listFull = listBuff.ToList(); }
// Extract all the segements public void ExtractSegments(byte[] rawImage, int imageW, int imageH) { int nCurrPos = 0; int nCurrVal = 0; for (int y = 0; y < mapH; y++) { for (int x = 0; x < mapW; x++) { if (map[y * imageW + x] == -1) { nCurrPos = y * imageW + x; nCurrVal = rawImage[y * imageW + x]; List <Point> segment = ExtractSingleSegment(rawImage, imageW, imageH, x, y, nCurrVal); CSegment seg = new CSegment(segment, this.INDEXER); listFull.Add(seg); } } } }
// get the color by index. public Color GetColorByIndex(int nIndex) { CSegment seg = listFull.ElementAt(nIndex); return(seg.c); }
// get segment points by index. have to run after extraction public List <Point> GetAllPointsByIndex(int nIndex) { CSegment seg = listFull.ElementAt(nIndex); return(seg.list.ToList()); }