Example #1
0
        public void MatchShape(string url)
        {
            double[] ts   = new double[7];
            double[] s    = new double[7];
            ulong    disS = 0;

            ImageProc myImage = new ImageProc(url);

            myImage.GetShapeFeature(ref s);

            var shape = GetAllShp();

            foreach (Image_Shape sd in shape)
            {
                disS = 0;

                ts[0] = (double)sd.s1;
                ts[1] = (double)sd.s2;
                ts[2] = (double)sd.s3;
                ts[3] = (double)sd.s4;
                ts[4] = (double)sd.s5;
                ts[5] = (double)sd.s6;
                ts[6] = (double)sd.s7;

                disS       = ImageProc.CalEuclidDistance(s, ts, 4);
                sd.Distant = Math.Sqrt(disS);
            }

            ImageData.SubmitChanges();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name     = name_box.Text;
            string category = category_box.Text;
            string period   = period_box.Text;
            string museum   = museum_box.Text;
            string intro    = intro_box.Text;

            System.Diagnostics.Debug.Write(Session["path"]);
            const int num = 128;
            //计算图像中已标定的文物目标的特征值
            ImageProc roiImg = new ImageProc(Session["path"].ToString());

            int[] hist_hsv = new int[num];
            roiImg.GetHSVHistogram(hist_hsv);
            //string str_hsv = GetCharaStr(hist_hsv, num);    //color descriptor
            Image_Color newColor = new Image_Color();

            System.Diagnostics.Debug.Write(hist_hsv);
            double[] shape_hu = new double[7];
            roiImg.GetShapeFeature(ref shape_hu);     //Shape descriptor
            Image_Shape newShape = new Image_Shape();

            System.Diagnostics.Debug.Write(shape_hu);
            SqlServerDataBase sdb = new SqlServerDataBase();

            string stroresqlstring = "insert into Image_info(Url,Tag,Intro,category,Museum,Period) values ('" + Image1.ImageUrl + "','" + name + "','" + intro + "','" + category + "','" + museum + "','" + period + "')";
            bool   stroeFlag       = sdb.Insert(stroresqlstring, null);

            if (stroeFlag == true)
            {
                Response.Write("<script>alert('保存成功!');</script>");
            }
            else
            {
                Response.Write("<script>alert(\"" + sdb.ErrorMessage + "\");</script>");
            }
        }
Example #3
0
        public void ReCalShape()
        {
            double[] m_hu = new double[7];

            var imgInfo = GetAllInfo();

            foreach (Image_Info img in imgInfo)
            {
                //ImageProc myImage = new ImageProc(System.Web.HttpContext.Current.Server.MapPath("~/image_repository/") + img.Url);
                //使用标记处理过的图片
                ImageProc myImage = new ImageProc(HttpContext.Current.Server.MapPath("~/image/roi/") + img.Url);
                myImage.GetShapeFeature(ref m_hu);

                Image_Shape imgShp = GetSingleImgShp((int)img.ShapeID);
                imgShp.s1 = m_hu[0];
                imgShp.s2 = m_hu[1];
                imgShp.s3 = m_hu[2];
                imgShp.s4 = m_hu[3];
                imgShp.s5 = m_hu[4];
                imgShp.s6 = m_hu[5];
                imgShp.s7 = m_hu[6];
            }
            ImageData.SubmitChanges();
        }
Example #4
0
        //Insert one image record into database
        public void InsertImage(string tag, int caid, int pid, int mid, string intro, string id)
        {
            const int num = 128;

            Image_Info newImg = new Image_Info();

            newImg.ID         = GetNewId();
            newImg.Tag        = tag;
            newImg.CategoryID = caid;
            newImg.PeriodID   = pid;
            newImg.MuseumID   = mid;
            newImg.Intro      = intro;
            newImg.Url        = id;

            ImageProc myImage = new ImageProc(System.Web.HttpContext.Current.Server.MapPath("~/image/temp/") + id);

            myImage.SaveImage(System.Web.HttpContext.Current.Server.MapPath("~/image/repo/") + id);
            myImage.SaveMiniImage(System.Web.HttpContext.Current.Server.MapPath("~/image/repo/mini/") + id, 200);

            //计算图像中已标定的文物目标的特征值
            ImageProc roiImg = new ImageProc(System.Web.HttpContext.Current.Server.MapPath("~/image/roi/") + id);

            int[] hist_hsv = new int[num];
            roiImg.GetHSVHistogram(hist_hsv);
            string      str_hsv  = GetCharaStr(hist_hsv, num); //color descriptor
            Image_Color newColor = new Image_Color();

            double[] shape_hu = new double[7];
            roiImg.GetShapeFeature(ref shape_hu);     //Shape descriptor
            Image_Shape newShape = new Image_Shape();


            int newId;

            if (ImageData.Image_Color.Count() == 0)
            {
                newId = 0;
            }
            else
            {
                newId = ImageData.Image_Color.Max(cid => cid.ID) + 1;
            }

            newColor.ID    = newId;
            newImg.ColorID = newId;
            newColor.HSV   = str_hsv;

            newShape.ID    = newId;
            newImg.ShapeID = newId;
            newShape.s1    = shape_hu[0];
            newShape.s2    = shape_hu[1];
            newShape.s3    = shape_hu[2];
            newShape.s4    = shape_hu[3];
            newShape.s5    = shape_hu[4];
            newShape.s6    = shape_hu[5];
            newShape.s7    = shape_hu[6];

            ImageData.Image_Shape.InsertOnSubmit(newShape);
            ImageData.Image_Color.InsertOnSubmit(newColor);
            ImageData.Image_Info.InsertOnSubmit(newImg);
            ImageData.SubmitChanges();
        }