Example #1
0
        // creates hsl map from given image files - params should be files List<File> - or even better image files
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static java.util.Map<String, FractionHSLData> getFractionHSLDataForDirectory(java.io.File imgDir, org.neuroph.imgrec.image.Dimension samplingResolution) throws java.io.IOException
        public static IDictionary <string, FractionHSLData> getFractionHSLDataForDirectory(File imgDir, Dimension samplingResolution)
        {
            if (!imgDir.Directory)
            {
                throw new System.ArgumentException("The given file must be a directory.  Argument is: " + imgDir);
            }

            IDictionary <string, FractionHSLData> map = new Dictionary <string, FractionHSLData>();
            ImageFilesIterator imagesIterator         = new ImageFilesIterator(imgDir);

            try
            {
                while (imagesIterator.hasNext())
                {
                    File          imgFile = imagesIterator.next();
                    BufferedImage img     = ImageIO.read(imgFile);
                    BufferedImage image   = ImageUtilities.resizeImage(img, samplingResolution.Width, samplingResolution.Height);

                    string filenameOfCurrentImage = imgFile.Name;
                    //String filenameOfCurrentImage = imagesIterator.getFilenameOfCurrentImage();
                    StringTokenizer st = new StringTokenizer(filenameOfCurrentImage, ".");
                    map[st.nextToken()] = new FractionHSLData(image);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            return(map);
        }
Example #2
0
        /// <summary>
        /// Loads images from the specified dir, scales to specified resolution and creates RGB data for each image
        /// Puts HSL data in a Map using filenames as keys, and returns that map </summary>
        /// <param name="imgDir"> </param>
        /// <param name="samplingResolution"> </param>
        /// <exception cref="java.io.IOException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static java.util.Map<String, FractionRgbData> getFractionRgbDataForDirectory(java.io.File imgDir, org.neuroph.imgrec.image.Dimension samplingResolution) throws java.io.IOException
        public static IDictionary <string, FractionRgbData> getFractionRgbDataForDirectory(File imgDir, Dimension samplingResolution)
        {
            if (!imgDir.Directory)
            {
                throw new System.ArgumentException("The given file must be a directory.  Argument is: " + imgDir);
            }

            IDictionary <string, FractionRgbData> rgbDataMap = new Dictionary <string, FractionRgbData>();

            ImageFilesIterator imagesIterator = new ImageFilesIterator(imgDir);

            while (imagesIterator.hasNext())
            {
                File  imgFile = imagesIterator.next();
                Image img     = ImageFactory.getImage(imgFile);
                img = ImageSampler.downSampleImage(samplingResolution, img);
                string          filenameOfCurrentImage = imagesIterator.FilenameOfCurrentImage;
                StringTokenizer st = new StringTokenizer(filenameOfCurrentImage, ".");
                rgbDataMap[st.nextToken()] = new FractionRgbData(img);
            }
            return(rgbDataMap);
        }
 public FilenameFilterAnonymousInnerClassHelper(ImageFilesIterator outerInstance, File dir)
 {
     this.outerInstance = outerInstance;
     this.dir           = dir;
 }