如何将图像转换成纹身? [英] How to convert an image into tattoo?

查看:143
本文介绍了如何将图像转换成纹身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的tattoolater在该应用程序我需要将图像转换(这是从相机或从图库中选择)到文身......

Am working the app for tattoolater in that i required to convert an image(which is taken from camera or selected from gallery)into tattoo...

我的要求是类似以下

   我发现了一个样本code从github上 https://github.com/DrewDahlman/ImageFilter/tree/master/Android/project

I found a sample code from github https://github.com/DrewDahlman/ImageFilter/tree/master/Android/project

其imagefiltering ..

its for imagefiltering..

我不知道这是正确的过程,将图像转换为纹身或不

i dont know is this correct process to convert an image to tattoo or not

如果有人知道了这个纹身在Android的请建议我,我用Google搜索了很多

if anybody know for this tattoo in android please suggest me i googled a lot

在此先感谢。

推荐答案

您需要一个不同的过滤器:

you need a difference filter:

1)你calc下水平的差异(在这​​里你将有垂直段)

1) you calc the horizontal difference (here you'll have vertical segments)

2)你calc下的垂直差异(这里,水平段)

2) you calc the vertical difference (here, horizontal segments)

3)您或两个地图,找到轮廓

3) you OR the two maps, finding the outlines

4)重新建立一个位图对象,如果你愿意的话

4) recreate a Bitmap object, if you wish to do so

像(编者):

int[] pixels;
int width = yourbitmap.getWidth();
int height = yourbitmap.getHeight();
yourbitmap.getPixels(pixels, 0, width, 0, 0, width, height);

// transform grayscale
int[] image = new int[width*height];
for (int y=0; y<height; y++)
    for (int x=0; x<width; x++)
    {
        int pixel = image[y*width + x];
        image[y*width + x] = (Color.red(pixel) + Color.green(pixel) + Color.blue(pixel))/3;
    }

// calculate diff_x (vertical segments)
int[] dx = new int[width*height];

for (int y=0; y<height; y++)
    for (int x=0; x<width; x++)
        dx[y*width + x] = (x==0 || y== 0 ? 0 : Math.abs(image[y*width + x] - image[y*width + x-1]));

// calculate diff_y (horizontal segments)
int[] dy = new int[width*height];

for (int y=0; y<height; y++)
    for (int x=0; x<width; x++)
        dy[y*width + x] = (x==0 || y== 0 ? 0 : Math.abs(image[y*width+x] - image[(y-1)*width+x])); 


// when the color intensity is higher than THRESHOLD, accept segment
// you'll want a slider to change THRESHOLD values
bool[] result = new bool[width*height];
const int THRESHOLD = 60; // adjust this value

for (int y=0; y<height; y++)
    for (int x=0; x<width; x++)
        result[y*width + x] = (dx[y*width + x] > THRESHOLD || dy[y*width + x] > THRESHOLD);

Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
for (int y=0; y<height; y++)
    for (int x=0; x<width; x++)
               result.setPixel(x, y, result[y*width+x]? Color.Black : Color.White);

这篇关于如何将图像转换成纹身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆