我应该如何用Java进行图像处理?

发布于 2024-10-04 15:56:06 字数 334 浏览 3 评论 0原文

我正在制作一个小程序,可以让用户裁剪出图像的一部分并保存它。对于裁剪,我将实现一个“魔杖”式的工具。我可以在 Matlab 中完成所有这些工作,但我在弄清楚 Java 库时遇到了一些麻烦。以下是我需要执行的一些任务:

  • 通过 (x,y) 随机访问图像中的像素并返回单个对象(java.awt.Color、ARGB int、short[],等等 - 只要我不单独处理通道)
  • 从布尔值[][]创建一个alpha通道
  • 创建一个初始化为绿色的N乘M图像

有专业人士可以帮助我吗?只需从你的头脑中提取一些代码片段就可以了。

非常感谢,

尼尔

I'm making an applet that lets users crop out a piece of an image and save it. For cropping, I'm going to implement a "magic wand"-esque tool. I can do all this in Matlab but i'm having some trouble figuring out the Java libraries. Here are a few tasks I need to perform:

  • Randomly access pixels in an image by (x,y) and return a single object (java.awt.Color, ARGB int, short[], whatever -- as long as I'm not dealing with channels individually)
  • Create an alpha channel from a boolean[ ][ ]
  • Create a N by M image that's initialized to green

Any pros out there who can help me? Just some code snippets off the top of your head would be fine.

Many thanks,

Neal

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随波逐流 2024-10-11 15:56:06

您想要使用 Java2D 库。具体来说,您希望使用库中的 BufferedImage 类来处理图像。您可以访问各个像素并执行上面指定的所有操作。 Sun/Oracle 有一个很好的教程来帮助您开始正确的方向。该教程的第二部分介绍了如何创建 Alpha 通道。哦,要访问单个像素,您需要使用 WritableRaster 类。所以你可以做这样的事情。希望这能让你开始。

WritableRaster imageRaster = Bufferedimg.getRaster();
//use java random generation to get a random x and y coordinate, then call this to access the pixel
imageRaster.getPixel(x, y,(int[])null);

You want to use the Java2D libraries. Specifically, you want to use the BufferedImage class from the library to deal with your images. You can access individual pixels and do all of the things you have specified above. Sun/Oracle has a good tutorial to get you started in the right direction. The second part in that tutorial goes over creating an alpha channel. Oh, and to access individual pixels, you want to use the WritableRaster class. So you can do something like this. Hope this gets you started.

WritableRaster imageRaster = Bufferedimg.getRaster();
//use java random generation to get a random x and y coordinate, then call this to access the pixel
imageRaster.getPixel(x, y,(int[])null);
凉风有信 2024-10-11 15:56:06

ImageJ是一个成熟的开源图像处理框架,支持宏、插件和许多其他功能

ImageJ is a mature, open-source image processing framework that supports macros, plugins and a host of other features.

别闹i 2024-10-11 15:56:06

Marvin 是一个可以帮助您的 Java 图像处理框架。它提供了过滤、特征提取、形态分析、转换、分割等算法。此外,其架构支持使用相同算法的实时视频处理。

Marvin is a Java image processing framework that can help you. It provides algorithms for filtering, feature extraction, morphological analysis, tranformations, segmentation and so forth. Moreover, its architecture supports real-time video processing with the same algorithms.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文