示例#1
0
        public List <DTOs.ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List <ImageRecord> rtnImageList = new List <ImageRecord>();

            RgbProjections queryProjections;

            using (Bitmap bitmap = ImageUtility.ResizeBitmap(new Bitmap(queryImagePath), 100, 100))
            {
                queryProjections = new RgbProjections(ImageUtility.GetRgbProjections(bitmap));
            }
            BinaryAlgoRepository <List <RGBProjectionRecord> > repo = new BinaryAlgoRepository <List <RGBProjectionRecord> >();
            List <RGBProjectionRecord> AllImage = repo.Load();

            foreach (var imgInfo in AllImage)
            {
                var dist = imgInfo.RGBProjection.CalculateSimilarity(queryProjections);
                if (dist > 0.8d)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            rtnImageList = rtnImageList.OrderByDescending(x => x.Distance).ToList();
            return(rtnImageList);
        }
        public List <ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List <ImageRecord> rtnImageList = new List <ImageRecord>();

            double[,] queryHistogram;
            using (Image img = Image.FromFile(queryImagePath))
            {
                queryHistogram = BhattacharyyaCompare.Bhattacharyya.CalculateNormalizedHistogram(img);
            }
            BinaryAlgoRepository <List <BhattacharyyaRecord> > repo = new BinaryAlgoRepository <List <BhattacharyyaRecord> >();
            List <BhattacharyyaRecord> AllImage = repo.Load();

            foreach (var imgInfo in AllImage)
            {
                double[,] norHist = SingleToMulti(imgInfo.NormalizedHistogram);
                var dist = BhattacharyyaCompare.Bhattacharyya.CompareHistogramPercDiff(queryHistogram, norHist);
                if (dist < 3)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            rtnImageList = rtnImageList.OrderBy(x => x.Distance).ToList();
            return(rtnImageList);
        }
示例#3
0
        public List<ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List<ImageRecord> rtnImageList = new List<ImageRecord>();

            string queryImageCompressHash;
            using (Bitmap bmp = new Bitmap(System.Drawing.Image.FromFile(queryImagePath)))
            {
                queryImageCompressHash = SimilarImage.GetCompressedImageHashAsString(bmp);
            }
            BinaryAlgoRepository<List<PHashImageRecord>> repo = new BinaryAlgoRepository<List<PHashImageRecord>>();
            List<PHashImageRecord> AllImage = repo.Load();
            foreach (var imgInfo in AllImage)
            {
                var dist = SimilarImage.CompareHashes(queryImageCompressHash, imgInfo.CompressHash);
                if (dist > 0.8)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }

            rtnImageList = rtnImageList.OrderByDescending(x => x.Distance).ToList();

            return rtnImageList;
        }
示例#4
0
        public List <ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List <ImageRecord> rtnImageList = new List <ImageRecord>();

            string queryImageCompressHash;

            using (Bitmap bmp = new Bitmap(System.Drawing.Image.FromFile(queryImagePath)))
            {
                queryImageCompressHash = SimilarImage.GetCompressedImageHashAsString(bmp);
            }
            BinaryAlgoRepository <List <PHashImageRecord> > repo = new BinaryAlgoRepository <List <PHashImageRecord> >();
            List <PHashImageRecord> AllImage = repo.Load();

            foreach (var imgInfo in AllImage)
            {
                var dist = SimilarImage.CompareHashes(queryImageCompressHash, imgInfo.CompressHash);
                if (dist > 0.8)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }

            rtnImageList = rtnImageList.OrderByDescending(x => x.Distance).ToList();

            return(rtnImageList);
        }
示例#5
0
        public List <ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List <ImageRecord> rtnImageList = new List <ImageRecord>();

            CEDD_Descriptor.CEDD cedd = new CEDD_Descriptor.CEDD();

            int goodMatchDistance = 35;

            if (argument != null && argument is Int32)
            {
                goodMatchDistance = (int)argument;
            }


            double[] queryCeddDiscriptor;
            using (Bitmap bmp = new Bitmap(Image.FromFile(queryImagePath)))
            {
                queryCeddDiscriptor = cedd.Apply(bmp);
            }

            Stopwatch sw = Stopwatch.StartNew();
            BinaryAlgoRepository <List <CEDDRecord> > repo = new BinaryAlgoRepository <List <CEDDRecord> >();
            List <CEDDRecord> AllImage = (List <CEDDRecord>)repo.Load();

            sw.Stop();
            Debug.WriteLine("Load tooked {0} ms", sw.ElapsedMilliseconds);

            sw.Reset(); sw.Start();

            foreach (var imgInfo in AllImage)
            {
                double[] ceddDiscriptor = imgInfo.CEDDDiscriptor;
                var      dist           = CEDD_Descriptor.CEDD.Compare(queryCeddDiscriptor, ceddDiscriptor);
                if (dist < goodMatchDistance)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            sw.Stop();
            Debug.WriteLine("Query tooked {0} ms", sw.ElapsedMilliseconds);
            rtnImageList = rtnImageList.OrderBy(x => x.Distance).ToList();
            return(rtnImageList);
        }
示例#6
0
        public List<ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List<ImageRecord> rtnImageList = new List<ImageRecord>();
            CEDD_Descriptor.CEDD cedd = new CEDD_Descriptor.CEDD();

            int goodMatchDistance = 35;
            if (argument != null && argument is Int32)
                goodMatchDistance = (int)argument;

            double[] queryCeddDiscriptor;
            using (Bitmap bmp = new Bitmap(Image.FromFile(queryImagePath)))
            {
                queryCeddDiscriptor = cedd.Apply(bmp);
            }

            Stopwatch sw = Stopwatch.StartNew();
            BinaryAlgoRepository<List<CEDDRecord>> repo = new BinaryAlgoRepository<List<CEDDRecord>>();
            List<CEDDRecord> AllImage = (List<CEDDRecord>)repo.Load();
            sw.Stop();
            Debug.WriteLine("Load tooked {0} ms", sw.ElapsedMilliseconds);

            sw.Reset(); sw.Start();

            foreach (var imgInfo in AllImage)
            {
                double[] ceddDiscriptor = imgInfo.CEDDDiscriptor;
                var dist = CEDD_Descriptor.CEDD.Compare(queryCeddDiscriptor, ceddDiscriptor);
                if (dist < goodMatchDistance)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            sw.Stop();
            Debug.WriteLine("Query tooked {0} ms", sw.ElapsedMilliseconds);
            rtnImageList = rtnImageList.OrderBy(x => x.Distance).ToList();
            return rtnImageList;
        }
示例#7
0
        public List<ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List<ImageRecord> rtnImageList = new List<ImageRecord>();

            double[,] queryHistogram;
            using (Image img = Image.FromFile(queryImagePath))
            {
                queryHistogram = BhattacharyyaCompare.Bhattacharyya.CalculateNormalizedHistogram(img);
            }
            BinaryAlgoRepository<List<BhattacharyyaRecord>> repo = new BinaryAlgoRepository<List<BhattacharyyaRecord>>();
            List<BhattacharyyaRecord> AllImage = repo.Load();
            foreach (var imgInfo in AllImage)
            {
                double[,] norHist = SingleToMulti(imgInfo.NormalizedHistogram);
                var dist = BhattacharyyaCompare.Bhattacharyya.CompareHistogramPercDiff(queryHistogram, norHist);
                if (dist < 3)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            rtnImageList = rtnImageList.OrderBy(x => x.Distance).ToList();
            return rtnImageList;
        }
示例#8
0
        public List<DTOs.ImageRecord> QueryImage(string queryImagePath, object argument = null)
        {
            List<ImageRecord> rtnImageList = new List<ImageRecord>();

            RgbProjections queryProjections;

            using (Bitmap bitmap = ImageUtility.ResizeBitmap(new Bitmap(queryImagePath), 100, 100))
            {
                queryProjections = new RgbProjections(ImageUtility.GetRgbProjections(bitmap));
            }
            BinaryAlgoRepository<List<RGBProjectionRecord>> repo = new BinaryAlgoRepository<List<RGBProjectionRecord>>();
            List<RGBProjectionRecord> AllImage = repo.Load();
            foreach (var imgInfo in AllImage)
            {
                var dist = imgInfo.RGBProjection.CalculateSimilarity(queryProjections);
                if (dist > 0.8d)
                {
                    imgInfo.Distance = dist;
                    rtnImageList.Add(imgInfo);
                }
            }
            rtnImageList = rtnImageList.OrderByDescending(x => x.Distance).ToList();
            return rtnImageList;
        }