Beispiel #1
0
 private IImage CalcHaar(IImage img)
 {
     return(HarrWavelet.Transform(img, levels - 1, cutoff));
 }
Beispiel #2
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            int[] res    = r.FindResultsSimple();
            int   numcat = FindNumCategories(r.TestCategories);

            cat = new Category[numcat + 1];
            for (int i = 0; i < numcat + 1; i++)
            {
                cat[i] = new Category();
            }

            total      = r.Length;
            notmatched = 0;

            for (int i = 0; i < r.Length; i++)
            {
                int tc = r.TestCategory(i);
                int bc = r.BaseCategory(res[i]);

                cat[tc].total++;

                if (cat[tc].image == null)
                {
                    double scale;
                    IImage img = null;

                    for (int j = 0; j < r.OriginalBaseImages.Length; j++)
                    {
                        if (r.BaseCategory(j) == tc)
                        {
                            img = r.OriginalBaseImages[j];
                            if (first)
                            {
                                break;
                            }
                        }
                    }

                    if (img == null)
                    {
                        cat[tc].image = new Gdk.Pixbuf(Assembly.GetEntryAssembly(), "no-base.png");
                    }
                    else
                    {
                        if (img.W > img.H)
                        {
                            scale = img.W / 48.0;
                        }
                        else
                        {
                            scale = img.H / 48.0;
                        }

                        Gdk.Pixbuf tmp = img.CreatePixbuf();
                        cat[tc].image = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale),
                                                        Gdk.InterpType.Bilinear);
                    }
                }

                if (tc != bc && r.Match[i])
                {
                    cat[tc].notmatched++;
                    notmatched++;
                }
            }

            _workdone = true;
        }
Beispiel #3
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            itest = new Gdk.Pixbuf[r.Length];
            ibase = new Gdk.Pixbuf[r.OriginalBaseImages.Length];

            double scale;

            for (int i = 0; i < itest.Length; i++)
            {
                IImage img = r.OriginalTestImages[i];

                if (img.W > img.H)
                {
                    scale = img.W / 32.0;
                }
                else
                {
                    scale = img.H / 32.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                itest[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            for (int i = 0; i < ibase.Length; i++)
            {
                IImage img = r.OriginalBaseImages[i];

                if (img.W > img.H)
                {
                    scale = img.W / 32.0;
                }
                else
                {
                    scale = img.H / 32.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                ibase[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            res = new IResult[r.Length];
            for (int i = 0; i < r.Length; i++)
            {
                res[i] = r[i];
            }

            match = r.FindResultsSimple();

            for (int i = 0; i < r.Length; i++)
            {
                if (!r.Match[i])
                {
                    match[i] = -1;
                }
            }

            _workdone = true;
        }
Beispiel #4
0
        public override void Work()
        {
            ICommResult r = _in[0] as ICommResult;

            itest  = new Gdk.Pixbuf[r.Length];
            thumbs = new Gdk.Pixbuf[r.Length];
            ibase  = new Gdk.Pixbuf[r.OriginalBaseImages.Length];

            double scale;

            for (int i = 0; i < itest.Length; i++)
            {
                IImage _img = r.OriginalTestImages[i];
                IImage img  = new IImage(_img.BPP, _img.W, _img.H, _img.Data, invert);

                if (invert)
                {
                    img.Invert();
                }

                if (img.W > img.H)
                {
                    scale = img.W / 256.0;
                }
                else
                {
                    scale = img.H / 256.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                itest[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);

                if (img.W > img.H)
                {
                    scale = img.W / 64.0;
                }
                else
                {
                    scale = img.H / 64.0;
                }

                thumbs[i] = itest[i].ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            for (int i = 0; i < ibase.Length; i++)
            {
                IImage _img = r.OriginalBaseImages[i];
                IImage img  = new IImage(_img.BPP, _img.W, _img.H, _img.Data, invert);

                if (invert)
                {
                    img.Invert();
                }

                if (img.W > img.H)
                {
                    scale = img.W / 256.0;
                }
                else
                {
                    scale = img.H / 256.0;
                }

                Gdk.Pixbuf tmp = img.CreatePixbuf();
                ibase[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
            }

            res = r.FindResultsSimple();

            cat1 = r.BaseCategories;
            cat2 = r.TestCategories;

            match = r.Match;

            _workdone = true;
        }
Beispiel #5
0
        public override void Work()
        {
            taskListMutex.WaitOne();
            tasks.Clear();
            taskListMutex.ReleaseMutex();

            if (cat.Count == 0)
            {
                throw new PluginException(Catalog.GetString("No categories in list"));
            }

            bool MultiThreading = Eithne.Config.Get("engine/blockthreads", false);

            ArrayList test_cl = new ArrayList();
            ArrayList test_il = new ArrayList();

            ArrayList base_cl = new ArrayList();
            ArrayList base_il = new ArrayList();

            for (int i = 0; i < cat.Count; i++)
            {
                foreach (Img img in (cat[i] as Category).Files)
                {
                    if (img.IsTest)
                    {
                        test_cl.Add(i);
                        test_il.Add(img.Name);
                    }
                    else
                    {
                        base_cl.Add(i);
                        base_il.Add(img.Name);
                    }
                }
            }

            if (test_il.Count == 0)
            {
                throw new PluginException(Catalog.GetString("There are no test images selected"));
            }
            if (base_il.Count == 0)
            {
                throw new PluginException(Catalog.GetString("There are no base images selected"));
            }

            int[] test_categories = (int[])test_cl.ToArray(typeof(int));
            int[] base_categories = (int[])base_cl.ToArray(typeof(int));

            IImage[] test_imgarray = new IImage[test_il.Count];
            IImage[] base_imgarray = new IImage[base_il.Count];

            totalImages = test_il.Count + base_il.Count;

            if (MultiThreading)
            {
                // test
                TaskInfo ti1 = new TaskInfo(test_imgarray, test_il, 0, test_il.Count / 2);
                TaskInfo ti2 = new TaskInfo(test_imgarray, test_il, test_il.Count / 2, test_il.Count);

                taskListMutex.WaitOne();
                tasks.Add(ti1);
                tasks.Add(ti2);
                taskListMutex.ReleaseMutex();

                Thread t1 = new Thread(ti1.TaskWork);
                Thread t2 = new Thread(ti2.TaskWork);

                t1.Start();
                t2.Start();

                t1.Join();
                t2.Join();

                int t1progress = ti1.Progress;
                int t2progress = ti2.Progress;

                // base
                ti1 = new TaskInfo(base_imgarray, base_il, 0, base_il.Count / 2, t1progress);
                ti2 = new TaskInfo(base_imgarray, base_il, base_il.Count / 2, base_il.Count, t2progress);

                taskListMutex.WaitOne();
                tasks.Clear();
                tasks.Add(ti1);
                tasks.Add(ti2);
                taskListMutex.ReleaseMutex();

                t1 = new Thread(ti1.TaskWork);
                t2 = new Thread(ti2.TaskWork);

                t1.Start();
                t2.Start();

                t1.Join();
                t2.Join();
            }
            else
            {
                TaskInfo t = new TaskInfo(test_imgarray, test_il, 0, test_il.Count);
                tasks.Add(t);
                t.TaskWork();
                t = new TaskInfo(base_imgarray, base_il, 0, base_il.Count);
                t.TaskWork();
            }

            _out    = new CommSocket(2);
            _out[0] = new ICommImage(base_imgarray, base_imgarray, base_categories);
            _out[1] = new ICommImage(test_imgarray, test_imgarray, test_categories);

            taskListMutex.WaitOne();
            tasks.Clear();
            taskListMutex.ReleaseMutex();

            _workdone = true;
        }
Beispiel #6
0
 private IImage CalcHaar(IImage img)
 {
     return(HarrWavelet.Inverse(img, levels - 1));
 }