有什么算法可以把彩色图片处理成像素化
这种使用像素密度代替颜色的处理方法叫什么??
最像的是波尔卡点 但是又不太一样
求教有什么算法或者处理方法可以实现这种图像
原图
回答:
搞到算法啦
public Bitmap doDither(Bitmap bitmapIn, String color) throws IOException { int i;
int i2;
Bitmap bitmap = bitmapIn;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[][] iArr = (int[][]) Array.newInstance(Integer.TYPE, new int[]{width, height});
for (i = 0; i < width; i++) {
for (i2 = 0; i2 < height; i2++) {
iArr[i][i2] = DitherUtils.getAverage(bitmap.getPixel(i, i2));
}
}
int[][] dither = dither(iArr, height, width);
int[][] dither2 = DitherUtils.dither(new int[][]{new int[]{255, 84, 255}, new int[]{93, 255, 62}, new int[]{255, 132, 60}}, 3, 3);
Bitmap createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (i2 = 0; i2 < height; i2++) {
for (i = 0; i < width; i++) {
int rtrt = ((dither[i][i2] << 16) | (dither[i][i2] << 8)) | dither[i][i2];
createBitmap.setPixel(i, i2, rtrt);
}
}
return createBitmap;
}
private int[][] dither(int[][] pixel, int height, int width) {
int i = 0;
while (i < height) {
int i2 = i < height + -1 ? 1 : 0;
int i3 = 0;
while (i3 < width) {
int i4 = i3 > 0 ? 1 : 0;
Object obj = i3 < width + -1 ? 1 : null;
int i5 = pixel[i3][i];
int i6 = i5 < 128 ? 0 : 255;
pixel[i3][i] = i6;
int i7 = i5 - i6;
int[] iArr;
if (obj != null) {
iArr = pixel[i3 + 1];
iArr[i] = iArr[i] + ((i7 * 7) / 16);
}
int i8;
if ((i4 & i2) != 0) {
iArr = pixel[i3 - 1];
i8 = i + 1;
iArr[i8] = iArr[i8] + ((i7 * 3) / 16);
}
if (i2 != 0) {
iArr = pixel[i3];
i8 = i + 1;
iArr[i8] = iArr[i8] + ((i7 * 5) / 16);
}
if (!(obj == null || i2 == 0)) {
iArr = pixel[i3 + 1];
i8 = i + 1;
iArr[i8] = iArr[i8] + (i7 / 16);
}
i3++;
}
i++;
}
return pixel;
}
回答:
可以搜索关键词“二值化”
以上是 有什么算法可以把彩色图片处理成像素化 的全部内容, 来源链接: utcz.com/a/158253.html