Пример #1
0
        public void MatchColor(string dir, string id)
        {
            const int num = 128;    //the number of hsv histogram's value

            ulong dis_hsv = 0;

            int[] trg_hsv = new int[num];
            int[] src_hsv = new int[num];

            ImageProc myImage = new ImageProc(dir + id);

            myImage.GetHSVHistogram(src_hsv);

            myImage.SaveHistImg(HttpContext.Current.Server.MapPath("~/image/hist/") + id);

            var chara = GetAllClr();

            foreach (Image_Color cd in chara)
            {
                trg_hsv = ConvertCharaStr(cd.HSV, num);

                dis_hsv = ImageProc.CalEuclidDistance(src_hsv, trg_hsv, 128);

                cd.Distant = (double)(Math.Sqrt(dis_hsv));
            }
            ImageData.SubmitChanges();
        }
Пример #2
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();
        }