I have to extract all color of image in Android without using ML (Google vision, IBM Visual Recognition).
I had check below option.
1.Palette The palette library attempts to extract the following six color profiles.
2. Get color of a particular pixel
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;
}
if I break bitmap in small size then find out color and save in list. Then there is time taken and OutOfMemoryError.
Please suggest any library to find color of images.
Edit
Pick from gallary
InputStream stream = getContentResolver().openInputStream(
data.getData());
bitmap = BitmapFactory.decodeStream(stream);
stream.close()
Get Color code from Pixel
HashMap<Integer,Integer> colorList=new HashMap<>();
private void getAllColorInImages(Bitmap bitmap)
{
colorList.clear();
if(bitmap==null)
return;
int width=bitmap.getWidth();
int height=bitmap.getHeight();
for(int i=0;i<width;i++)
{
for(int j=0;j<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);
}