コード例 #1
0
        public void LoadImageUnits(string folder)
        {
            string fileName = "";

            try
            {
                DirectoryInfo TheFolder = new DirectoryInfo(folder);

                // clear
                this.m_listImageUnit.Clear();

                // progress bar
                int nCount = TheFolder.GetFiles().Count();
                this.form.SetMaxValueOfProgressBar(nCount);

                int ind    = 0;
                int border = 0;

                // for each
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    fileName = folder + "\\" + NextFile.Name;

                    // create image
                    ImageUnit image = new ImageUnit();
                    image.LoadImage(fileName);

                    // calc image tone
                    image.CalcImageTone();

                    // add
                    this.m_listImageUnit.Add(image);

                    // update progress bar
                    ++ind;
                    this.form.UpdateProgressBar(ind);

                    // memory collect
                    ++border;
                    if (border >= 50)
                    {
                        GC.Collect();
                        border = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Load Image Units failed [" + fileName + "]" + ex.Message);
            }
        }
コード例 #2
0
        private ImageUnit MatchEachUnit(int r, int g, int b)
        {
            float     tmp;
            float     minValue     = Int32.MaxValue;
            ImageUnit minImageUnit = null;

            foreach (ImageUnit image in this.m_listImageUnit)
            {
                tmp = this.CalcDistance(r, g, b, image.R, image.G, image.B);
                if (tmp < minValue)
                {
                    minValue     = tmp;
                    minImageUnit = image;
                }
            }
            return(minImageUnit);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: plvmail/ImageSplicing
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            m_imageUnitOnShow          = null;
            this.m_imageUnitOnShowPosX = e.X;
            this.m_imageUnitOnShowPosY = e.Y;


            int unitX = Param.Canvas_Width / Param.Unit_Count;
            int unitY = Param.Canvas_Height / Param.Unit_Count;

            int ix = e.X / unitX;
            int iy = e.Y / unitY;

            if (ix >= 0 && ix < Param.Unit_Count && iy >= 0 && iy < Param.Unit_Count)
            {
                try
                {
                    m_imageUnitOnShow = this.imageSplicing.ListMatchedUnit[iy, ix];
                }
                catch (Exception ex)
                { }
            }
            Invalidate();
        }