Sobel边缘检测机器人 [英] Sobel Edge Detection in Android

查看:137
本文介绍了Sobel边缘检测机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我正在为Android开发,我想向用户展示他们已经拍摄的图像(类似于下面的示例的东西)的边缘检测到的版本​​的应用程序的一部分。

As part of an application that I'm developing for Android I'd like to show the user an edge-detected version of an image they have taken (something similar to the example below).

替代文字

要做到这一点,我一直在寻找的Sobel算子,以及如何在Java中实现它。然而,许多我发现化妆使用的对象和方法在AWT中的例子(像这样的例子)不是机器人的一部分。

To achieve this I've been looking at the Sobel operator and how to implement it in Java. However, many of the examples that I've found make use of objects and methods found in AWT (like this example) that isn't part of Android.

我的问题是真的话,那Android的提供AWT的已在上面的例子中所使用的任何功能的替代品?如果我们重写只使用内置的Andr​​oid的库,例如,我们将如何做呢?

My question is then really, does Android provide any alternatives to the features of AWT that have been used in the above example? If we were to rewrite that example just using the libraries built into Android, how would we go about it?

推荐答案

因为你没有BufferedImage的Andr​​oid中,你可以自己做所有的基本操作:

since you don't have BufferedImage in Android, you can do all the basic operations yourself:

Bitmap b = ...
width = b.getWidth();
height = b.getHeight();
stride = b.getRowBytes();
for(int x=0;x<b.getWidth();x++)
  for(int y=0;y<b.getHeight();y++)
    {
       int pixel = b.getPixel(x, y);
       // you have the source pixel, now transform it and write to destination 
    }

你可以看到,这包括你需要移植的AWT例子几乎所有的东西。 (只是改变了convolvePixel功能)

as you can see, this covers almost everything you need for porting that AWT example. (just change the 'convolvePixel' function)

这篇关于Sobel边缘检测机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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