Tag: 灰度

单色灰度图像,获得像素的强度

我试图在单色“灰度”图像中导出特定像素的强度值。 我有一些伪代码,但到目前为止,我一直无法实现真正​​有效的东西。 /** * Retrieve the intensity value at location (‘row’, ‘column’) of the image ‘img’ and return it * Note: * – the 2D image is stored as an 8bit, 1D, row-major array of type byte * – the data type byte is signed in Java * – Slide 27 of chapter 2 introduces […]

如何在不失透明度的情况下将图像转换为灰度?

我在将带有透明像素的彩色图像转换为灰度时遇到问题。 我在这个网站上搜索并发现了相关的问题,但我没有能够用来解决我的问题。 我已经定义了一个方法“convertType”,如下所示: /*—————————— attempts to convert the type of the image argument to the chosen type for example: BufferedImage newImage= ImageUtilities.convertType(oldImage, BufferedImage.TYPE_3BYTE_BGR); 11/28/2013 WARNING-it remains to be seen how well this method will work for various type conversions ——————————*/ public static BufferedImage convertType (BufferedImage image,int newType){ if (image.getType() == newType){ return (image); }else { […]

将short 转换为灰度图像

我正在使用aparapi写一个Buddhabrot分形发生器。 我让它的OpenCL部分工作,产生一个代表每个像素的单维数组。 我将最终图像的尺寸作为最终的int,并编写了代码来获取该数组中任意点的索引。 我想将此保存为图像,我正在尝试使用带有TYPE_USHORT_GRAY的BufferedImage。 这是我到目前为止所拥有的: BufferedImage image=new BufferedImage(VERTICAL_PIXELS, HORIZONTAL_PIXELS, BufferedImage.TYPE_USHORT_GRAY); for(int i=0; i<VERTICAL_PIXELS; i++) for(int k=0; k<HORIZONTAL_PIXELS; k++) image.setRGB(k, i, normalized[getArrayIndex(k,i,HORIZONTAL_PIXELS)]); 问题是,我不知道将RGB设置为什么。 我需要做什么?