Пример #1
0
        /* Calssifies one given image vector */
        public static string ClassifyVector(ImageVector vector, ref double[] how_much_pictures, ref double[] how_much_good, bool how_is_picture)
        {
            bool paramExist;

            string result = String.Empty;

            for (int j = 0; j < ImageVector.NUMBER_OF_PARAMETERS; j++)
            {
                vector.DicParameter.TryGetValue(ImageVector.getParameterNameByIndex(j) , out paramExist);
                if (paramExist)
                {
                    result += getParameterClassification(ImageVector.getParameterNameByIndex(j), vector.getParameterByIndex(j));
                    Preparation_remainder(j, ImageVector.getParameterNameByIndex(j), how_is_picture, vector.getParameterByIndex(j), ref  how_much_pictures, ref how_much_good);
                }
            }

            //System.Windows.Forms.MessageBox.Show("classify " + result);
            return result;
        }
Пример #2
0
        /* Calssifies one given image vector
         * the old function for testing only*/
        public static string ClassifyVector(ImageVector vector)
        {
            bool paramExist;
            string result = String.Empty;

            for (int i = 0; i < ImageVector.NUMBER_OF_PARAMETERS; i++)
            {
                vector.DicParameter.TryGetValue(ImageVector.getParameterNameByIndex(i), out paramExist);
                if (paramExist)
                    result += getParameterClassification(ImageVector.getParameterNameByIndex(i), vector.getParameterByIndex(i));
            }

            return result;
        }
Пример #3
0
        /* Writing to XML parameters of pictures in a given folder */
        public static bool WritePicturesParametersToXML(string folderPath, string filePath, Dictionary<ImageVector.ImageParameters, bool> dictionary)
        {
            ImageVector vector;
            _progress = 0;

            // Get list of files in the folder (assuming all are images)
            string[] files = LoadImages(folderPath);

            int numOfFiles = files.Length;
            int filesProcessed = 0;

            // Create an XmlWriterSettings object with the correct options.
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = ("\t");
            settings.OmitXmlDeclaration = true;

            // Open text file for writing
            XmlWriter xml = XmlWriter.Create(filePath, settings);

            xml.WriteStartDocument(true);

            string folderTitle = folderPath.Substring(folderPath.LastIndexOf('\\') + 1);
            xml.WriteStartElement(folderTitle);

            // Write each image parameters to file
            foreach (string file in files)
            {
                // Convert pic to vector
                vector = new ImageVector(file, dictionary);

                // Write XML
                string title = file.Substring(file.LastIndexOf('\\') + 1);
                xml.WriteStartElement(title);

                for (int i = 0; i < ImageVector.NUMBER_OF_PARAMETERS; i++)
                {
                    ImageVector.ImageParameters currentParam = ImageVector.getParameterNameByIndex(i);
                    if (dictionary[currentParam])
                        xml.WriteElementString(currentParam.ToString(), vector.getParameterByIndex(i).ToString());
                }

                xml.WriteEndElement();

                filesProcessed++;
                _progress = (filesProcessed * 100) / numOfFiles;
            }
            xml.WriteEndElement();
            xml.WriteEndDocument();
            xml.Close();

            _progress = 0;

            return true;
        }
Пример #4
0
        /*
         * copy one imageVector into matrix
         */
        public static void convertImageVectorToMatrix(ImageVector image, out Matrix<float> imageCopy)
        {
            int prepCount = ImageVector.NUMBER_OF_PARAMETERS;

            imageCopy = new Matrix<float>(1, prepCount);
            for (int i = 0; i < prepCount; i++)
                imageCopy.Data[0, i] = (float)image.getParameterByIndex(i);
        }