Beispiel #1
0
 public blob_tag(blob_tag tag)
 {
     index     = -1;
     time      = tag.time;
     rec       = tag.rec;
     check     = tag.check;
     Image_bin = tag.Image_bin;
 }
Beispiel #2
0
        // standart report
        public static void CreateStandartReport3(List <Bitmap> list /*,  int[] sample*/)
        {
            GC.Collect();

            MembersMorphoParameters mmp = MembersMorphoParameters.Deserialization();

            int inx = 0;

            Bitmap[]   src   = new Bitmap[list.Count];
            blob_tag[] blobs = new blob_tag[src.Length];

            foreach (Bitmap image in list)
            {
                src[inx++] = image;
            }

            ConfigSetting cfg   = SettingsManager.Instance.GetCurrent(System.Windows.Forms.Application.StartupPath);
            mmxRtfStore   store = new mmxRtfStore();

            store.AddRTF(Application.StartupPath + @"\reports\blank.rtf");


            // draw images
            for (int i = 0; i < src.Length; i++)
            {
                blobs[i] = (blob_tag)src[i].Tag;
                Bitmap bsrc = blobs[i].Image_bgr.Bitmap; //src[i].Clone(new Rectangle(0,0,src[i].Width , src[i].Height), PixelFormat.Format24bppRgb);
                Bitmap bbin = blobs[i].Image_bin.Bitmap;


                if (false && bsrc.Width > cfg.Report.ImgWidth)
                {
                    Size size = new Size(cfg.Report.ImgWidth, cfg.Report.ImgHeigth);
                    bsrc = resize(bsrc, size, true);
                    bbin = resize(bbin, size, false);
                }

                store.AddText((cfg.Report.ImgOriental) ? "  Source / Binarised images:" : "  Source images:");
                store.AddParagraph();
                store.AddImage(bsrc);

                if (!cfg.Report.ImgOriental)
                {
                    store.AddText("  Binarised images:");
                    store.AddParagraph();
                }

                store.AddImage(bbin);
                store.AddParagraph();
            }

            // draw histograms
            string[,] toRep = new string[mmp.countToReport, blobs.Length];
            string[] colNames = new string[mmp.countToReport];
            int      counter  = 0;
            int      j        = 0;

            for (int i = 0; i < 16; i++)
            {
                if (mmp.mp[i].ToReport)
                {
                    string   filtname = FilterName(mmp.mp[i].name, "mkm");
                    string   s        = "Histogram of " + filtname + " of particles ";
                    double[] z        = Filter(mmp.mp[i].name, blobs);

                    colNames[counter] = mmp.mp[i].name;
                    string[] tmp = FilterTable(mmp.mp[i].name, blobs);
                    for (j = 0; j < blobs.Length; j++)
                    {
                        toRep[counter, j] = tmp[j];
                    }
                    counter++;
                    if (z != null)
                    {
                        store.AddHistogram(s, mmp.mp[i].name, "", "", z, 10, 5, 2, cfg.Report.HistoWidth, cfg.Report.HistoHeigth, true);
                        store.AddParagraph();
                    }
                }
            }
            counter--;

            // draw tables
            if (colNames.Length > 0)
            {
                string[] filname = FilterName(colNames, "mkm");
                store.AddTable(toRep, filname, "Morpho Parameters of particles");
            }

            // formula
            //FormulaArea fa = new FormulaArea(blobs, (new CoefRangeXML()).Exec());
            //decimal formula = fa.Exec();
            //store.AddText(fa.Formula, new Font("Courier New", 9, FontStyle.Regular));


            // save rep to tmp file
            store.SaveAndShow();

            GC.Collect();
        }
Beispiel #3
0
        public static blob_tag[] FilterOuter(blob_tag[] blobs, double exactMin, double exactMax, string param)
        {
            if (blobs == null)
            {
                return(null);
            }

            ArrayList al = new ArrayList();

            for (int i = 0; i < blobs.Length; i++)
            {
                switch (param)
                {
                case "Angle":
                    if (blobs[i].orientation <= exactMin || blobs[i].orientation >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Area":
                    if (((blobs[i].area != null) ? blobs[i].area.value : 0) >= exactMin && ((blobs[i].area != null) ? blobs[i].area.value : 0) <= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "BigLen":
                    if (((blobs[i].maxAxis != null) ? blobs[i].maxAxis.value : 0) >= exactMin && ((blobs[i].maxAxis != null) ? blobs[i].maxAxis.value : 0) <= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Compactness":
                    if (blobs[i].compactness <= exactMin || blobs[i].compactness >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "ConvArea":
                    if (((blobs[i].convexity_area != null) ? blobs[i].convexity_area.value : 0) <= exactMin || ((blobs[i].convexity_area != null) ? blobs[i].convexity_area.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "ConvCompactness":
                    if (blobs[i].convexity_compactness <= exactMin || blobs[i].convexity_compactness >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Convexity":
                    //if (blobs[i].convexity <= exactMin || blobs[i].convexity >= exactMax)
                    al.Add(blobs[i]);
                    break;

                case "ConvPerimeter":
                    if (((blobs[i].convexity_perimetr != null) ? blobs[i].convexity_perimetr.value : 0) <= exactMin || ((blobs[i].convexity_perimetr != null) ? blobs[i].convexity_perimetr.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Elongation":
                    if (blobs[i].elongation <= exactMin || blobs[i].elongation >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Perimeter":
                    if (((blobs[i].perimetr != null) ? blobs[i].perimetr.value : 0) <= exactMin || ((blobs[i].perimetr != null) ? blobs[i].perimetr.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Rmax":
                    if (((blobs[i].Rmax != null) ? blobs[i].Rmax.value : 0) <= exactMin || ((blobs[i].Rmax != null) ? blobs[i].Rmax.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Rmin":
                    if (((blobs[i].Rmin != null) ? blobs[i].Rmin.value : 0) <= exactMin || ((blobs[i].Rmin != null) ? blobs[i].Rmin.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                //case "RoughnessBArea":
                //    if (blobs[i].RoughnessBAreaK <= exactMin || blobs[i].RoughnessBAreaK >= exactMax)
                //        al.Add(blobs[i]);
                //    break;
                case "Roundness":
                    if (blobs[i].roundness <= exactMin || blobs[i].roundness >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "SmallLen":
                    if (((blobs[i].minAxis != null) ? blobs[i].minAxis.value : 0) <= exactMin || ((blobs[i].minAxis != null) ? blobs[i].minAxis.value : 0) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;

                case "Rmax-Rmin":
                    if ((((blobs[i].Rmax != null) ? blobs[i].Rmax.value : 0) - ((blobs[i].Rmin != null) ? blobs[i].Rmin.value : 0)) <= exactMin || (((blobs[i].Rmax != null) ? blobs[i].Rmax.value : 0) - ((blobs[i].Rmin != null) ? blobs[i].Rmin.value : 0)) >= exactMax)
                    {
                        al.Add(blobs[i]);
                    }
                    break;
                }
            }

            blob_tag[] ret = new blob_tag[al.Count];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = (blob_tag)al[i];
            }
            return(ret);
        }
Beispiel #4
0
        public static void CreateLocalReport0(List <Bitmap> srcMaster, List <Bitmap> srcSlave, List <long []> link)
        {
            GC.Collect();

            MembersMorphoParameters mmp   = MembersMorphoParameters.Deserialization();
            ConfigSetting           cfg   = SettingsManager.Instance.GetCurrent(System.Windows.Forms.Application.StartupPath);
            mmxRtfStore             store = new mmxRtfStore();

            blob_tag[] blobsMaster = new blob_tag[srcMaster.Count];
            blob_tag[] blobsSlave  = new blob_tag[srcSlave.Count];

            store.AddRTF(Application.StartupPath + @"\reports\blank.rtf");

            int good = 0;
            int bad  = 0;

            // draw images
            for (int i = 0; i < srcMaster.Count; i++)
            {
                bool isPaire = (link != null && link.Count > i && link[i][1] > -1);

                blobsMaster[i] = (blob_tag)srcMaster[i].Tag;
                Bitmap bsrcMaster = blobsMaster[i].Image_bgr.Bitmap;//srcMaster[i].Clone(new Rectangle(0, 0, srcMaster[i].Width, srcMaster[i].Height), PixelFormat.Format24bppRgb);
                Bitmap bbinMaster = blobsMaster[i].Image_bin.Bitmap;
                Bitmap bsrcSlave  = null;
                Bitmap bbinSlave  = null;

                if (isPaire)
                {
                    Bitmap slaveBitmap = getSlave(srcSlave, link[i][1]);
                    blobsSlave[i] = (blob_tag)slaveBitmap.Tag;
                    bsrcSlave     = blobsSlave[i].Image_bgr.Bitmap;
                    bbinSlave     = blobsSlave[i].Image_bin.Bitmap;
                }

                if (false && bsrcMaster.Width > cfg.Report.ImgWidth)
                {
                    Size size = new Size(cfg.Report.ImgWidth, cfg.Report.ImgHeigth);
                    bsrcMaster = resize(bsrcMaster, size, true);
                    bbinMaster = resize(bbinMaster, size, false);
                    bsrcSlave  = resize(bsrcSlave, size, true);
                    bbinSlave  = resize(bbinSlave, size, false);
                }

                string resultat;
                if (blobsMaster[i].check || (isPaire && blobsSlave[i].check))
                {
                    resultat = "bad";
                    bad++;
                }
                else
                {
                    resultat = "good";
                    good++;
                }
                // make report ...
                {
                    store.AddParagraph();

                    store.AddText($"Sample #{i + 1} is {resultat}");

                    store.AddParagraph();

                    store.AddImage(bsrcMaster);
                    store.AddImage(bbinMaster);
                    store.AddText(" - source / binarised images from camera #1");


                    store.AddParagraph();

                    if (isPaire)
                    {
                        store.AddImage(bsrcSlave);
                        store.AddImage(bbinSlave);
                        store.AddText(" - source / binarised images from camera #2");
                    }

                    //                    store.AddParagraph();
                }
                {
                    string[,] toRep = new string[mmp.countToReport, 2];
                    string[] colNames = new string[mmp.countToReport];
                    int      counter  = 0;
                    for (int ix = 0; ix < 16; ix++)
                    {
                        if (mmp.mp[ix].ToReport)
                        {
                            colNames[counter] = mmp.mp[ix].name;
                            blob_tag[] arr   = (isPaire)? new blob_tag[] { blobsMaster[i], blobsSlave[i] } : new blob_tag[] { blobsMaster[i] };
                            string[]   items = FilterTable(mmp.mp[ix].name, arr);
                            for (int j = 0; j < arr.Length; j++)
                            {
                                toRep[counter, j] = items[j];
                            }
                            counter++;
                        }
                    }
                    counter--;

                    // draw tables
                    if (colNames.Length > 0)
                    {
                        string[] filname = FilterName(colNames, "mkm");
                        store.AddTable(toRep, filname, $"morpho parameters of sample #{i+1}");
                    }
                }
            }


            store.AddParagraph();
            store.AddText($"Total conclusion by report: total detect samples - {srcMaster.Count} ( good - {good }, bad - {bad} )");


            // save rep to tmp file
            store.SaveAndShow();

            GC.Collect();
        }