Monochromes Graustufenbild, um die Intensität eines Pixels zu erhalten

Ich versuche, einen Intensitätswert für ein bestimmtes Pixel in einem monochromen "Graustufen" -Bild abzuleiten. Ich habe einen Pseudocode, aber bisher war ich nicht in der Lage, etwas zu implementieren, das wirklich funktioniert.

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

Antworten auf die Frage(1)

Ihre Antwort auf die Frage