示例#1
0
        //----------------------ComputeEFs()----------------
        public void ComputeEFs(ImgComparison imgComparison, string imagesFolder)
        //Euclidean or Corr
        {
            ImageList = new List<MyImage>();
            
            EVList = new List<EvEvec>();
            // Scan Stored Image directory and add every jpg to
           
            try //Storing each image in ImageList
            {
                DirectoryInfo dirInfo = new DirectoryInfo(imagesFolder);
                if (!dirInfo.Exists)
                    throw new DirectoryNotFoundException(imagesFolder + "folder does not exist,");

                foreach (FileInfo nextFile in dirInfo.GetFiles())
                {
                    if (nextFile.Extension.ToUpper() == ".JPG")
                        this.ImageList.Add(new MyImage(nextFile.FullName, "II", imageWidth, imageHeight, ImgFormat.TwentyFourBit, imgComparison)); // Euclidean or Corr
                    else
                        if (nextFile.Extension.ToUpper() == ".GIF")                   
                            this.ImageList.Add(new MyImage(nextFile.FullName, "II",imageWidth, imageHeight, ImgFormat.EightBit, imgComparison));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "Error creating the ImageList..");
            }

            AdjustAllImages(); // subtract mean image from each image
            ComputeCovMatrix();
            ComputeEigenValuesEigenVectors();
            ComputeEigenFaces();
            ComputeKnownFaceSpace(); // projection of images onto reduced dim

        }
示例#2
0
        public MyImage(string fname, string id, int width, int height, ImgFormat imf, ImgComparison imc)
        {
            FileInfo finfo   = new FileInfo(fname);
            string   dirName = finfo.Directory.Name;

            this.FileNameShort = finfo.Name;
            this.Id            = id;
            this.FileName      = fname;
            imgCompareMode     = imc;
            ReadPic(imf, width, height); // read the picture into an 1-D array
            FindImageMean();
            this.ImgVectorAdjM = new double[width * height];
            this.FSV           = new double[width * height];
        }