/// <summary> /// Gets the largest blob /// </summary> /// <param name="imgSrc"></param> /// <param name="imgRender"></param> private void FilterByMaximumBlob(IplImage imgSrc, IplImage imgDst) { CvBlobs blobs = new CvBlobs(); imgDst.Zero(); blobs.Label(imgSrc); CvBlob max = blobs.GreaterBlob(); if (max == null) { return; } blobs.FilterByArea(max.Area, max.Area); blobs.FilterLabels(imgDst); }
private static void FilterByMaximalBlob(IplImage imgSrc, IplImage imgDst) { using (CvBlobs blobs = new CvBlobs()) using (IplImage imgLabelData = new IplImage(imgSrc.Size, CvBlobLib.DepthLabel, 1)) { imgDst.Zero(); blobs.Label(imgSrc, imgLabelData); CvBlob max = blobs[blobs.GreaterBlob()]; if (max == null) { return; } blobs.FilterByArea(max.Area, max.Area); blobs.FilterLabels(imgLabelData, imgDst); } }
public static IplImage test(IplImage target) { CvBlobs blobs = new CvBlobs(); IplImage lableImg = new IplImage(target.Size, CvBlobLib.DepthLabel, 1); IplImage retImg = new IplImage(target.Size, BitDepth.U8, 1); blobs.Label(target); CvBlob max = blobs.GreaterBlob(); if (max == null) { return(target); } blobs.FilterByArea(max.Area, max.Area); blobs.FilterLabels(retImg); return(retImg); }
/// <summary> /// ラベリングにより最大の面積の領域を残す /// </summary> /// <param name="imgSrc"></param> /// <param name="imgRender"></param> private void FilterByMaximalBlob(IplImage imgSrc, IplImage imgDst) { CvBlobs blobs = new CvBlobs(); imgDst.Zero(); blobs.Label(imgSrc); CvBlob max = blobs.GreaterBlob(); if (max == null) return; blobs.FilterByArea(max.Area, max.Area); blobs.FilterLabels(imgDst); }
/// <summary> /// Draw a binary image with the blobs that have been given. (cvFilterLabels) /// </summary> /// <param name="blobs">List of blobs to be drawn.</param> /// <param name="imgOut">Output binary image (depth=IPL_DEPTH_8U and nchannels=1).</param> public static void FilterLabels(CvBlobs blobs, Mat imgOut) { if (blobs == null) throw new ArgumentNullException(nameof(blobs)); blobs.FilterLabels(imgOut); }
/// <summary> /// Draw a binary image with the blobs that have been given. (cvFilterLabels) /// </summary> /// <param name="blobs">List of blobs to be drawn.</param> /// <param name="imgOut">Output binary image (depth=IPL_DEPTH_8U and nchannels=1).</param> public static void FilterLabels(CvBlobs blobs, IplImage imgOut) { if (blobs == null) throw new ArgumentNullException("blobs"); blobs.FilterLabels(imgOut); }