PixelGrabber vs getRGB中哪一个更快? [英] Which amongst PixelGrabber vs getRGB is faster?

查看:64
本文介绍了PixelGrabber vs getRGB中哪一个更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过捕获图像像素来实现图像上的 Hill Cipher 算法.事实证明,小的图像可以很好地加载.

I was trying to implement Hill Cipher algorithm on an image by grabbing its pixels. And it turns out that small images were loading fine.

但是对于较大的图像(8MP或12MP),加载速度很慢;因此写入图像的速度也很慢.

But with bigger images (8MP or 12MP), the loading is slow; and as a result writing the image is slow too.

我正在使用bufferedImage.getRGB(x,y)抓取每个像素,使用算法对其进行修改,然后使用bufferedImage.setRGB(x,y,rgb)同时写入像素.

I was grabbing each pixel using bufferedImage.getRGB(x,y), modifying it using the algorithm, and writing the pixels simultaneously using bufferedImage.setRGB(x,y,rgb).

现在,我需要一些建议来加快加载/写入速度.我想知道PixelGrabber是否会更好?

Now, I need some suggestions to make the loading/writing faster. I was wondering if PixelGrabber would be any better?

推荐答案

getRGB/setRGB 非常慢,因为每次调用它们时,它们都会进行大量的颜色空间检查和颜色转换.考虑到典型图像中的像素数量,绝对不是进行任何图像处理的方法.

getRGB/setRGB are very slow, because they do a lot of colorspace-checking and color-converting every time you call them. Definitely not the way to to any image-manipulation, considering the number of pixels in a typical image.

通过旧的PixelGrabber或BufferedImage.getRaster()将原始图像数据获取到数组中比较困难(您必须了解一些概念),但是运行起来要快得多.

Getting the raw image data into arrays via the old PixelGrabber or via BufferedImage.getRaster() is harder (you have to understand a few concepts) but runs much faster.

这篇关于PixelGrabber vs getRGB中哪一个更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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