title: Detect all color of Image in android
body: <p>I have to extract all color of image in Android without using ML (Google vision, IBM Visual Recognition).</p>
  
  <p>I had check below option.</p>
  
  <p><strong>1.<a href="https://developer.android.com/training/material/palette-colors" rel="nofollow noreferrer">Palette</a></strong>
  The palette library attempts to extract the following six color profiles.</p>
  
  <p><strong>2. Get color of a particular pixel</strong></p>
  
  <pre><code>public static int getDominantColor(Bitmap bitmap) {
  Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
  final int color = newBitmap.getPixel(0, 0);
  newBitmap.recycle();
  return color;
  }
  </code></pre>
  
  <p>if I break bitmap in small size then find out color and save in list.
  Then there is time taken and OutOfMemoryError.</p>
  
  <p>Please suggest any library  to find color of images.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Pick from gallary</p>
  
  <pre><code> InputStream stream = getContentResolver().openInputStream(
                          data.getData());
                  bitmap = BitmapFactory.decodeStream(stream);
                  stream.close()
  </code></pre>
  
  <p>Get Color code from Pixel</p>
  
  <pre><code>HashMap&lt;Integer,Integer&gt; colorList=new HashMap&lt;&gt;();
  private void  getAllColorInImages(Bitmap bitmap)
  {
      colorList.clear();
      if(bitmap==null)
          return;
      int width=bitmap.getWidth();
      int height=bitmap.getHeight();
      for(int i=0;i&lt;width;i++)
      {
          for(int j=0;j&lt;height;j++)
          {
              final int color = bitmap.getPixel(i, j);
              colorList.put(color,color);
  
          }
      }
      System.out.println("color list size "+colorList.size());
      System.out.println("color list Name "+colorList);
  
  }
  </code></pre>