Мне нужно извлечь все цвета изображения в Android без использования ML (Google vision, IBM Visual Recognition).
У меня была опция, указанная ниже.
1. Палитра Библиотека палитры пытается извлечь следующие шесть цветовых профилей.
2.Получить цвет определенного пикселя
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;
}
, если я разбью растровое изображение на небольшой размер, выясню цвет и сохраню в списке.Затем требуется время и OutOfMemoryError.
Пожалуйста, предложите любую библиотеку, чтобы найти цвет изображений.
Редактируйте
Выберите из галереи
InputStream stream = getContentResolver().openInputStream(
data.getData());
bitmap = BitmapFactory.decodeStream(stream);
stream.close()
Получить код цвета от 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);
}