【问题标题】:Monochrome grayscale image, get the intensity of a pixel单色灰度图,获取一个像素的强度
【发布时间】:2013-09-16 11:35:20
【问题描述】:

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

/**
 * 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;
}

【问题讨论】:

    标签: java image-processing pixel grayscale


    【解决方案1】:

    也许这会对你有所帮助:

    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();
    

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

    【讨论】:

      猜你喜欢
      • 2015-08-31
      • 2017-11-17
      • 1970-01-01
      • 2013-04-28
      • 1970-01-01
      • 2015-06-08
      • 2017-04-16
      • 1970-01-01
      • 2013-04-05
      相关资源
      最近更新 更多