示例#1
0
        /// <summary>
        /// Creates binary black and white training set for the specified image labels and rgb data
        /// white = 0 black = 1 </summary>
        /// <param name="imageLabels"> image labels </param>
        /// <param name="rgbDataMap"> map collection of rgb data </param>
        /// <returns> binary black and white training set for the specified image data </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.neuroph.core.data.DataSet createBlackAndWhiteTrainingSet(java.util.List<String> imageLabels, java.util.Map<String, FractionRgbData> rgbDataMap) throws org.neuroph.core.exceptions.VectorSizeMismatchException
        public static DataSet createBlackAndWhiteTrainingSet(List <string> imageLabels, IDictionary <string, FractionRgbData> rgbDataMap)
        {
            // TODO: Use some binarization image filter to do this; currently it works  with averaging RGB values
            int     inputCount  = rgbDataMap.Values.GetEnumerator().next().FlattenedRgbValues.length / 3;
            int     outputCount = imageLabels.Count;
            DataSet trainingSet = new DataSet(inputCount, outputCount);

            foreach (KeyValuePair <string, FractionRgbData> entry in rgbDataMap)
            {
                double[] inputRGB = entry.Value.FlattenedRgbValues;
                double[] inputBW  = FractionRgbData.convertRgbInputToBinaryBlackAndWhite(inputRGB);
                double[] response = createResponse(entry.Key, imageLabels);
                trainingSet.addRow(new DataSetRow(inputBW, response));
            }

            // set labels for output columns
            int inputSize = trainingSet.InputSize;

            for (int c = 0; c < trainingSet.OutputSize; c++)
            {
                trainingSet.setColumnName(inputSize + c, imageLabels[c]);
            }

            return(trainingSet);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is FractionRgbData))
            {
                return(false);
            }
            FractionRgbData other = (FractionRgbData)obj;

            return(Arrays.Equals(flattenedRgbValues, other.FlattenedRgbValues));
        }