getNumberOfColors() 공개 메소드

public getNumberOfColors ( ) : int
리턴 int
        public void getRGBData(ColorHistogram colorHist, double[][] data)
        {
            int size = colorHist.getNumberOfColors();

            for (int x = 0; x < size; x++)
            {
                data[x] = new double[3];
                int rgb = colorHist.getColor(x);
                data[x][0] = ((rgb & 0xFF0000) >> 16);
                data[x][1] = ((rgb & 0xFF00) >> 8);
                data[x][2] = (rgb & 0xFF);
            }
        }
        public string Apply(int k, string fn, string outImagePath)
        {
            Bitmap srcimg = new Bitmap(fn);
            pixels = ImageUtils.BitmapToArray1DIntRGB(srcimg);
            ColorHistogram colorHist = new ColorHistogram(pixels, false);
            int size = colorHist.getNumberOfColors();
            if (size <= k)
                srcimg.Save(outImagePath, ImageFormat.Png);
            else
            {
                double[][] data = new double[size][];

                getRGBData(colorHist, data);
                ClusterCollection clusters;
                KMeansParallel kMeans = new KMeansParallel();
                clusters = kMeans.ClusterDataSet(k, data);
                PaintRGB(srcimg, kMeans, clusters).Save(outImagePath, ImageFormat.Png);
            }
            return outImagePath;
        }
 public void GenerateColorPalette(string fn, List<int> qnum_list)
 {
     this.qnum_list = qnum_list;
     srcimg = new Bitmap(fn);
     width = srcimg.Width;
     height = srcimg.Height;
     pixels = ImageUtils.BitmapToArray1DIntRGB(srcimg);
     for (int i = 0; i < qnum_list.Count; i++)
     {
         color_table_list.Add( new Hashtable());
         ini_color_table_list.Add(new Hashtable());
     }
     ColorHistogram colorHist = new ColorHistogram(pixels, false);
     int K = colorHist.getNumberOfColors();
     findRepresentativeColors(K, colorHist);
 }
예제 #4
0
        public void YIQData(ColorHistogram colorHist, double[][] data)
        {
            int size = colorHist.getNumberOfColors();

            for (int x = 0; x < size; x++)
            {
                data[x] = new double[3];
                int rgb = colorHist.getColor(x);
                double[] yiq = RGB2YIQ(rgb);

                for (int y = 0; y < 3; y++)
                {
                    data[x][y] = yiq[y];
                }
            }
        }