单色灰度图像,获得像素的强度 [英] Monochrome grayscale image, get the intensity of a pixel

查看:284
本文介绍了单色灰度图像,获得像素的强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在单色灰度图像中导出特定像素的强度值。我有一些伪代码,但到目前为止,我一直无法实现真正​​有效的东西。

I'm attempting to derive an intensity value for a particular pixel in a monochrome "grayscale" image. I have some pseudocode, but thus far I've been unable to implement something that really works.

/**
 * 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 the representation of an image
 * @param img in row major format
 * @param row to evaluate
 * @param column to evaluate
 * @param width of img
 * @param height of img
 * @return the intensity value at row and column if within bounds, -1 otherwise
 */
public int getIntensityValue(byte[] img, int row, int column, int width, int height) {

       int intensity = img[row,column];

       return intensity;
}


推荐答案

也许这会对你有所帮助:

Maybe this will help you:

http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html

http://docs.oracle.com/javase/7 /docs/api/javax/imageio/ImageIO.html

BufferedImage img = ImageIO.read(new File("filePath.png"));

int sRbgColor = img.getRGB(int x, int y);

Color c = new Color(sRbgColor);
int red = c.getRed();
int green = c.getGreen();
int blue = c.getBlue();

如果它是单色的,那么红绿蓝应该相等。

If it's monochrome, then red green and blue should be equal.

这篇关于单色灰度图像,获得像素的强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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