I am currently working on a small project, which shall load an image from an URL, resize and change it's colour depth to only 16 colours using a specified colour palette. The main problem for me is, that I want a program, which I can use on an Android device and on a desktop computer. Do you know a good image processing library which works on both systems?
我目前正在开发一个小项目,该项目将从URL加载图像,调整大小并使用指定的调色板将其颜色深度更改为仅16种颜色。对我来说主要的问题是,我想要一个程序,我可以在Android设备和台式计算机上使用它。你知道一个适用于两个系统的好的图像处理库吗?
Thanks in advance.
提前致谢。
5 个解决方案
#1
11
There are several tools:
有几种工具:
#2
5
The answers on this page are quite dated as of February 2014. I was searching to find a free Android image processing library and I came across the Stanford lecture notes here: http://www.stanford.edu/class/ee368/Android/index.html
这个页面上的答案截止日期为2014年2月。我正在寻找一个免费的Android图像处理库,我在这里找到了斯坦福的讲义:http://www.stanford.edu/class/ee368/Android/的index.html
Investigating a bit further, I found out that they are using OpenCV in their course material. It has a Java interface (along with many other languages), but the library is written natively in C++. They state that:
进一步调查,我发现他们在课程材料中使用OpenCV。它有一个Java接口(以及许多其他语言),但该库是用C ++本地编写的。他们说:
Along with well-established companies like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota that employ the library, there are many startups such as Applied Minds, VideoSurf, and Zeitera, that make extensive use of OpenCV.
除了谷歌,雅虎,微软,英特尔,IBM,索尼,本田,丰田等知名公司,还有许多创业公司,如Applied Minds,VideoSurf和Zeitera,它们广泛使用OpenCV。
I am excited(!) to have found this, looking forward to going home and giving it a go.
我很兴奋(!)找到了这个,期待回家然后放手一搏。
#3
3
The Android NDK allows you to use an existing C/C++ library that does not require java.awt or any of the Android classes. For example, you could easily compile libpng as a shared library for Android and then write a JNI interface to pass images from the Java layer to the png library. Similarly, you will also be able to compile libpng as a shared library for your desktop computer and use it from there.
Android NDK允许您使用不需要java.awt或任何Android类的现有C / C ++库。例如,您可以轻松地将libpng编译为Android的共享库,然后编写JNI接口以将图像从Java层传递到png库。同样,您也可以将libpng编译为台式计算机的共享库,并从那里使用它。
I recently wrote a tutorial on how to compile open-source libraries for Android. If you browse the Android source, you will find some classes that use the skia graphics library via jni. I have not used skia before, but since Android has skia in its base framework, it should not be too difficult to get it to work in your app/desktop program.
我最近写了一篇关于如何为Android编译开源库的教程。如果您浏览Android源代码,您会发现一些通过jni使用skia图形库的类。我之前没有使用过skia,但由于Android在其基础框架中有skia,因此在app / desktop程序中使用它不应该太困难。
Writing cross-platform programs has been an area of active interest amongst the mobile developers community, and some engines such as libgdx have gotten really good at it. So what you are attempting is definitely possible.
编写跨平台程序一直是移动开发人员社区中一个积极关注的领域,而像libgdx这样的引擎已经非常擅长。所以你所尝试的绝对是可能的。
#4
1
Octoate,
I don't think there is a library that exists that does what you want, the reason for that is on non-mobile platform every graphical operation you are going to use in Java is going to use the Java2D rendering pipeline to some degree. On Android, this doesn't exist.
我不认为存在可以满足您需求的库,其原因是在非移动平台上,您将在Java中使用的每个图形操作都将在某种程度上使用Java2D渲染管道。在Android上,这不存在。
Android provides its own graphical pipeline for image manipulation and actually simplifies a lot of things that are more complicated in standard Java.
Android为图像处理提供了自己的图形管道,实际上简化了标准Java中更复杂的许多事情。
All that being said, it looks like you found a library (JJIL) that acts as an abstraction layer on top of these differences, in that case I would be a bit worried about performance and do some testing in your own code to see how it performs compared to the platform methods. For example, I saw this quote from JJIL:
总而言之,看起来你发现了一个库(JJIL)作为这些差异之上的抽象层,在这种情况下,我会对性能有点担心,并在你自己的代码中做一些测试,看看它是怎么回事执行与平台方法相比。例如,我从JJIL看到了这句话:
allows images to be converted from Android bitmaps into JJIL RgbImages
允许图像从Android位图转换为JJIL RgbImages
When I look at the source for RgbImages, it looks like the image data gets converted and stored in an internal array; all of those layers of abstraction are going to cost you CPU time and memory, especially as images on mobile devices get bigger due to higher resolution cameras and high-bandwidth connections.
当我查看RgbImages的源代码时,看起来图像数据被转换并存储在内部数组中;所有这些抽象层都会花费你的CPU时间和内存,特别是当移动设备上的图像由于更高分辨率的摄像头和高带宽连接而变大时。
This may not be that big of an issue, but again, you'll probably want to do some profiling/testing/performance comparisons.
这可能不是一个大问题,但同样,您可能想要进行一些分析/测试/性能比较。
#5
-3
Any pure Java library should work on both platforms. A Google search of "Java image processing library" produced several results. Try to find the lightest weight lib that serves your purposes since memory and CPU are limited on mobile devices.
任何纯Java库都应该适用于这两个平台。谷歌搜索“Java图像处理库”产生了几个结果。尝试找到最轻的lib,它可以满足您的需求,因为内存和CPU在移动设备上受到限制。
Barry
#1
11
There are several tools:
有几种工具:
#2
5
The answers on this page are quite dated as of February 2014. I was searching to find a free Android image processing library and I came across the Stanford lecture notes here: http://www.stanford.edu/class/ee368/Android/index.html
这个页面上的答案截止日期为2014年2月。我正在寻找一个免费的Android图像处理库,我在这里找到了斯坦福的讲义:http://www.stanford.edu/class/ee368/Android/的index.html
Investigating a bit further, I found out that they are using OpenCV in their course material. It has a Java interface (along with many other languages), but the library is written natively in C++. They state that:
进一步调查,我发现他们在课程材料中使用OpenCV。它有一个Java接口(以及许多其他语言),但该库是用C ++本地编写的。他们说:
Along with well-established companies like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota that employ the library, there are many startups such as Applied Minds, VideoSurf, and Zeitera, that make extensive use of OpenCV.
除了谷歌,雅虎,微软,英特尔,IBM,索尼,本田,丰田等知名公司,还有许多创业公司,如Applied Minds,VideoSurf和Zeitera,它们广泛使用OpenCV。
I am excited(!) to have found this, looking forward to going home and giving it a go.
我很兴奋(!)找到了这个,期待回家然后放手一搏。
#3
3
The Android NDK allows you to use an existing C/C++ library that does not require java.awt or any of the Android classes. For example, you could easily compile libpng as a shared library for Android and then write a JNI interface to pass images from the Java layer to the png library. Similarly, you will also be able to compile libpng as a shared library for your desktop computer and use it from there.
Android NDK允许您使用不需要java.awt或任何Android类的现有C / C ++库。例如,您可以轻松地将libpng编译为Android的共享库,然后编写JNI接口以将图像从Java层传递到png库。同样,您也可以将libpng编译为台式计算机的共享库,并从那里使用它。
I recently wrote a tutorial on how to compile open-source libraries for Android. If you browse the Android source, you will find some classes that use the skia graphics library via jni. I have not used skia before, but since Android has skia in its base framework, it should not be too difficult to get it to work in your app/desktop program.
我最近写了一篇关于如何为Android编译开源库的教程。如果您浏览Android源代码,您会发现一些通过jni使用skia图形库的类。我之前没有使用过skia,但由于Android在其基础框架中有skia,因此在app / desktop程序中使用它不应该太困难。
Writing cross-platform programs has been an area of active interest amongst the mobile developers community, and some engines such as libgdx have gotten really good at it. So what you are attempting is definitely possible.
编写跨平台程序一直是移动开发人员社区中一个积极关注的领域,而像libgdx这样的引擎已经非常擅长。所以你所尝试的绝对是可能的。
#4
1
Octoate,
I don't think there is a library that exists that does what you want, the reason for that is on non-mobile platform every graphical operation you are going to use in Java is going to use the Java2D rendering pipeline to some degree. On Android, this doesn't exist.
我不认为存在可以满足您需求的库,其原因是在非移动平台上,您将在Java中使用的每个图形操作都将在某种程度上使用Java2D渲染管道。在Android上,这不存在。
Android provides its own graphical pipeline for image manipulation and actually simplifies a lot of things that are more complicated in standard Java.
Android为图像处理提供了自己的图形管道,实际上简化了标准Java中更复杂的许多事情。
All that being said, it looks like you found a library (JJIL) that acts as an abstraction layer on top of these differences, in that case I would be a bit worried about performance and do some testing in your own code to see how it performs compared to the platform methods. For example, I saw this quote from JJIL:
总而言之,看起来你发现了一个库(JJIL)作为这些差异之上的抽象层,在这种情况下,我会对性能有点担心,并在你自己的代码中做一些测试,看看它是怎么回事执行与平台方法相比。例如,我从JJIL看到了这句话:
allows images to be converted from Android bitmaps into JJIL RgbImages
允许图像从Android位图转换为JJIL RgbImages
When I look at the source for RgbImages, it looks like the image data gets converted and stored in an internal array; all of those layers of abstraction are going to cost you CPU time and memory, especially as images on mobile devices get bigger due to higher resolution cameras and high-bandwidth connections.
当我查看RgbImages的源代码时,看起来图像数据被转换并存储在内部数组中;所有这些抽象层都会花费你的CPU时间和内存,特别是当移动设备上的图像由于更高分辨率的摄像头和高带宽连接而变大时。
This may not be that big of an issue, but again, you'll probably want to do some profiling/testing/performance comparisons.
这可能不是一个大问题,但同样,您可能想要进行一些分析/测试/性能比较。
#5
-3
Any pure Java library should work on both platforms. A Google search of "Java image processing library" produced several results. Try to find the lightest weight lib that serves your purposes since memory and CPU are limited on mobile devices.
任何纯Java库都应该适用于这两个平台。谷歌搜索“Java图像处理库”产生了几个结果。尝试找到最轻的lib,它可以满足您的需求,因为内存和CPU在移动设备上受到限制。
Barry