Sobel边缘检测机器人机器人、边缘、Sobel

由网友(光着脚丫°)分享简介:由于我正在为Android开发,我想向用户展示他们已经拍摄的图像(类似于下面的示例的东西)的边缘检测到的版本​​的应用程序的一部分。As part of an application that I'm developing for Android I'd like to show the user an edge-d...

由于我正在为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)

阅读全文

相关推荐

最新文章