コード例 #1
0
        public static void RecalculateOriginalROI(ROI original, TifFileInfo newFI, Point[] locs = null)
        {
            ROI roiOut = original.Duplicate();

            int max = roiOut.Type == 0 ? 1 : newFI.imageCount;

            for (int i = 0; i < max; i += newFI.sizeC)
            {
                var   points = roiOut.GetLocation(i + newFI.cValue);
                Point newP   = locs == null? new Point(newFI.xCompensation, newFI.yCompensation):locs[i];
                Point p;

                for (int ind = 0; ind < points.Length; ind++)
                {
                    p = points[ind];

                    p.X         = p.X - newP.X;
                    p.Y         = p.Y - newP.Y;
                    points[ind] = p;
                }

                roiOut.SetLocation(i, points);
            }

            newFI.roiList = new List <ROI> [newFI.sizeC];
            for (int c = 0; c < newFI.sizeC; c++)
            {
                newFI.roiList[c] = new List <ROI>();
            }

            newFI.roiList[0].Add(roiOut);

            if (newFI.sizeC > 1)
            {
                for (int c = 1; c < newFI.sizeC; c++)
                {
                    ROI newROI = roiOut.Duplicate();

                    for (int i = 0; i < newFI.imageCount; i += newFI.sizeC)
                    {
                        var points = roiOut.GetLocation(i);

                        newROI.SetLocation(i + c, points);
                    }

                    newFI.roiList[c].Add(newROI);
                }
            }
        }
コード例 #2
0
ファイル: MultiCropper.cs プロジェクト: GDanovski/AutoSobel2
        public static void RecalculateOriginalROI(ROI original, ROI modified, TifFileInfo newFI)
        {
            if (modified != null)
            {
                for (int i = 0; i < newFI.imageCount; i += newFI.sizeC)
                {
                    var   points = original.GetLocation(i);
                    Point newP   = modified.GetLocation(i)[0];
                    Point p;

                    for (int ind = 0; ind < points.Length; ind++)
                    {
                        p           = points[ind];
                        p.X         = p.X - newP.X;
                        p.Y         = p.Y - newP.Y;
                        points[ind] = p;
                    }

                    original.SetLocation(i, points);
                }
            }

            newFI.roiList = new List <ROI> [newFI.sizeC];
            for (int c = 0; c < newFI.sizeC; c++)
            {
                newFI.roiList[c] = new List <ROI>();
            }

            newFI.roiList[0].Add(original);

            if (newFI.sizeC > 1)
            {
                for (int c = 1; c < newFI.sizeC; c++)
                {
                    ROI newROI = original.Duplicate();

                    for (int i = 0; i < newFI.imageCount; i += newFI.sizeC)
                    {
                        var points = original.GetLocation(i);

                        newROI.SetLocation(i + c, points);
                    }

                    newFI.roiList[c].Add(newROI);
                }
            }
        }
コード例 #3
0
        public static ROI TransformToRect(TifFileInfo fi, ROI source)
        {
            if (source.Checked == true && source.Type == 1 && source.Shape > 1)
            {
                ROI dest = NewROI(fi);
                //dest.SetLocationAll(GetRoiNewLocations(source));
                Point[][] points = GetRoiNewLocations(source);

                for (int c = 0; c < fi.sizeC; c++)
                {
                    for (int i = fi.cValue, realC = c; i < fi.imageCount; i += fi.sizeC, realC += fi.sizeC)
                    {
                        dest.SetLocation(realC, points[i]);
                    }
                }

                dest.Width  = source.Width;
                dest.Height = source.Height;

                return(dest);
            }
            else if (source.Checked == true && source.Type == 1 && source.Shape <= 1)
            {
                ROI dest = NewROI(fi);
                //dest.SetLocationAll(GetRoiNewLocations(source));
                Point[][] points = source.GetLocationAll();

                for (int c = 0; c < fi.sizeC; c++)
                {
                    for (int i = fi.cValue, realC = c; i < fi.imageCount; i += fi.sizeC, realC += fi.sizeC)
                    {
                        dest.SetLocation(realC, points[i]);
                    }
                }

                dest.Width  = source.Width;
                dest.Height = source.Height;

                return(dest);
            }

            return(null);
        }