コード例 #1
0
ファイル: Resize.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            progress = 0;

            ICommImage socket = _in[0] as ICommImage;

            IImage[] i1 = socket.Images;
            IImage[] i2 = new IImage[i1.Length];

            for (int i = 0; i < i1.Length; i++)
            {
                Gdk.Pixbuf buf = i1[i].CreatePixbuf();

                Gdk.Pixbuf bufout = buf.ScaleSimple(i1[i].W / 2, i1[i].H / 2, mode);

                i2[i] = IImage.Create(bufout, i1[i].BPP);

                progress = (float)i / i1.Length;
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommImage(i2, socket.OriginalImages, socket.Categories);

            _workdone = true;
        }
コード例 #2
0
		public override void Work()
		{
			progress = 0;

			ICommImage socket = _in[0] as ICommImage;
			IImage[] img = socket.Images;
			IImage[] ret = new IImage[img.Length];

			if(splithalf)
				for(int i=0; i<img.Length; i++)
				{
					ret[i] = SplitHistogram(img[i]);
					progress = (float)i/img.Length;
				}
			else
				for(int i=0; i<img.Length; i++)
				{
					ret[i] = Histogram(img[i]);
					progress = (float)i/img.Length;
				}

			_out = new CommSocket(1);
			_out[0] = new ICommImage(ret, socket.OriginalImages, socket.Categories);

			_workdone = true;
		}
コード例 #3
0
ファイル: RGBSplit.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            progress = 0;

            ICommImage socket = _in[0] as ICommImage;

            IImage[] img = socket.Images;

            IImage[] res1 = new IImage[img.Length];
            IImage[] res2 = new IImage[img.Length];
            IImage[] res3 = new IImage[img.Length];

            for (int i = 0; i < img.Length; i++)
            {
                IImage[] rgb = Split(img[i]);

                res1[i] = rgb[0];
                res2[i] = rgb[1];
                res3[i] = rgb[2];

                progress = (float)i / img.Length;
            }

            _out    = new CommSocket(3);
            _out[0] = new ICommImage(res1, socket.OriginalImages, socket.Categories);
            _out[1] = new ICommImage(res2, socket.OriginalImages, socket.Categories);
            _out[2] = new ICommImage(res3, socket.OriginalImages, socket.Categories);


            _workdone = true;
        }
コード例 #4
0
        public override void Work()
        {
            progress = 0;
            ICommImage socket = _in[0] as ICommImage;

            IImage[] img = socket.Images;
            IImage[] ret = new IImage[img.Length * 2];

            int[]    cat     = new int[img.Length * 2];
            IImage[] origimg = new IImage[img.Length * 2];

            for (int i = 0; i < img.Length; i++)
            {
                ret[i * 2]     = img[i];
                ret[i * 2 + 1] = MirrorImage(img[i]);

                cat[i * 2]     = socket.Category(i);
                cat[i * 2 + 1] = socket.Category(i);

                origimg[i * 2]     = socket.OriginalImage(i);
                origimg[i * 2 + 1] = socket.OriginalImage(i);

                progress = (float)i / img.Length;
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommImage(ret, origimg, cat);

            _workdone = true;
        }
コード例 #5
0
ファイル: SimpleDB.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            progress = 0;

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

            int i = 0;

            IImage[] imgarray   = new IImage[_fl.Count];
            int[]    categories = new int[_fl.Count];

            foreach (string fn in _fl)
            {
                Gdk.Pixbuf buf = new Gdk.Pixbuf(fn);

                imgarray[i]   = IImage.Create(buf, Utility.IsBW(buf) ? BPP.Grayscale : BPP.RGB);
                categories[i] = i;

                i++;

                progress = (float)i / _fl.Count;
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommImage(imgarray, imgarray, categories);

            _workdone = true;
        }
コード例 #6
0
        public override void Work()
        {
            _out = new CommSocket(1);

            _out[0] = _in[0];

            _workdone = true;
        }
コード例 #7
0
ファイル: Best.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            ICommResult ires = _in[0] as ICommResult;

            int tcount = ires.Length;
            int bcount = ires[0].Length;

            double[][] points = new double[tcount][];
            for (int i = 0; i < tcount; i++)
            {
                points[i] = new double[bcount];
                for (int j = 0; j < bcount; j++)
                {
                    points[i][j] = 0;
                }
            }

            for (int i = 0; i < num; i++)
            {
                ICommResult r = _in[i] as ICommResult;

                if (r.Length != tcount || r[0].Length != bcount)
                {
                    throw new PluginException(Catalog.GetString("Incompatible data on input."));
                }

                // FIXME add configuration
                int[][] res = r.FindResults();

                for (int t = 0; t < tcount; t++)
                {
                    points[t][res[t][0]] += 1;

                    if (res[t].Length > 1)
                    {
                        points[t][res[t][1]] += 0.5;
                    }

                    if (res[t].Length > 2)
                    {
                        points[t][res[t][2]] += 0.25;
                    }
                }
            }

            IResult[] resarray = new IResult[tcount];

            for (int i = 0; i < tcount; i++)
            {
                resarray[i] = new IResult(points[i]);
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommResult(resarray, num, ires.OriginalBaseImages, ires.OriginalTestImages, ires.BaseCategories,
                                      ires.TestCategories, ires.Match);

            _workdone = true;
        }
コード例 #8
0
        public override void Work()
        {
            ICommImage socket = _in[0] as ICommImage;

            _out = new CommSocket(1);

            _out[0] = new ICommImage(socket.Images, socket.Images, socket.Categories);

            _workdone = true;
        }
コード例 #9
0
ファイル: Multiplier.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            _out = new CommSocket(num);

            for (int i = 0; i < num; i++)
            {
                _out[i] = _in[0];
            }

            _workdone = true;
        }
コード例 #10
0
ファイル: L0Mod.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            tasks.Clear();

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

            ICommImage socket1 = _in[0] as ICommImage;
            ICommImage socket2 = _in[1] as ICommImage;

            IImage[] img1 = socket1.Images;
            IImage[] img2 = socket2.Images;

            _out = new CommSocket(1);

            IResult[] res = new IResult[img2.Length];

            totalImages = img1.Length * img2.Length;

            if (MultiThreading)
            {
                TaskInfo ti1 = new TaskInfo(res, img1, img2, delta, 0, img2.Length / 2);
                TaskInfo ti2 = new TaskInfo(res, img1, img2, delta, img2.Length / 2, img2.Length);

                tasks.Add(ti1);
                tasks.Add(ti2);

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

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

                t1.Join();
                t2.Join();
            }
            else
            {
                TaskInfo t = new TaskInfo(res, img1, img2, delta, 0, img2.Length);
                tasks.Add(t);
                t.TaskWork();
            }

            _out[0] = new ICommResult(res, 0, socket1.OriginalImages, socket2.OriginalImages,
                                      socket1.Categories, socket2.Categories);

            tasks.Clear();

            _workdone = true;
        }
コード例 #11
0
ファイル: Desaturate.cs プロジェクト: zeta1999/eithne
        public override void Work()
        {
            ICommImage socket = _in[0] as ICommImage;

            IImage[] img = socket.Images;
            IImage[] res = new IImage[img.Length];
            _out = new CommSocket(1);

            for (int i = 0; i < img.Length; i++)
            {
                res[i] = Desaturate(img[i]);
            }

            _out[0] = new ICommImage(res, socket.OriginalImages, socket.Categories);

            _workdone = true;
        }
コード例 #12
0
ファイル: Engine.cs プロジェクト: zeta1999/eithne
        public EngineThread(Engine2 engine, Block b)
        {
            this.b      = b;
            this.engine = engine;

            b.Working = true;
            MainWindow.RedrawSchematic();

            try
            {
                if (b.Plugin.NumIn != 0)
                {
                    CommSocket cs = new CommSocket(b.Plugin.NumIn);

                    for (int i = 0; i < b.Plugin.NumIn; i++)
                    {
                        Socket other = b.SocketIn[i].Other;

                        if (other.Parent.Plugin.Out == null)
                        {
                            b.Working = false;
                            b         = other.Parent;
                            throw new PluginException(Catalog.GetString("Plugin has no data on output sockets."));
                        }

                        cs[i] = other.Parent.Plugin.Out[other.Num];
                    }

                    b.Plugin.In = cs;
                }

                Plugin = b.Plugin;
                t      = new Thread(ThreadedWork);
                t.Start();
            }
            catch (Exception e)
            {
                engine.Stop();

                b.ShowError = true;
                MainWindow.RedrawSchematic();
                new PluginError(e, b, false);
            }
        }
コード例 #13
0
        public override void Work()
        {
            progress = 0;

            ICommImage socket = _in[0] as ICommImage;

            IImage[] img = socket.Images;
            IImage[] res = new IImage[img.Length];
            _out = new CommSocket(1);

            for (int i = 0; i < img.Length; i++)
            {
                res[i]   = DCT(img[i]);
                progress = (float)i / img.Length;
            }

            _out[0] = new ICommImage(res, socket.OriginalImages, socket.Categories);

            FFTW.Cleanup();

            _workdone = true;
        }
コード例 #14
0
        public override void Work()
        {
            ICommResult ires = _in[0] as ICommResult;

            int tcount = ires.Length;
            int bcount = ires[0].Length;

            int[][] res = new int[y][];

            for (int i = 0; i < y; i++)
            {
                ICommResult r = _in[i] as ICommResult;

                if (r.Length != tcount || r[0].Length != bcount)
                {
                    throw new PluginException(Catalog.GetString("Incompatible data on input."));
                }

                res[i] = r.FindResultsSimple();
            }

            bool[] match = new bool[tcount];

            for (int i = 0; i < tcount; i++)
            {
                match[i] = true;
            }

            IResult[] resarray = new IResult[tcount];

            for (int i = 0; i < tcount; i++)
            {
                double[] tmp = new double[bcount];
                int[]    cnt = new int[bcount];
                int      j;

                for (j = 0; j < bcount; j++)
                {
                    tmp[j] = 0;
                    cnt[j] = 0;
                }

                for (j = 0; j < y; j++)
                {
                    if ((_in[j] as ICommResult).Match[i])
                    {
                        cnt[res[j][i]]++;
                    }
                }

                for (j = 0; j < bcount; j++)
                {
                    if (cnt[j] >= x)
                    {
                        tmp[j] = cnt[j];
                        break;
                    }
                }

                // no match
                if (j == bcount)
                {
                    match[i] = false;
                }

                resarray[i] = new IResult(tmp);
            }

            _out    = new CommSocket(1);
            _out[0] = new ICommResult(resarray, y, ires.OriginalBaseImages, ires.OriginalTestImages, ires.BaseCategories,
                                      ires.TestCategories, match);


            _workdone = true;
        }
コード例 #15
0
ファイル: ClassDB.cs プロジェクト: zeta1999/eithne
        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;
        }