I have an assignment to make a class based on another class called RBGColor which I don't have the source code for but I am told represents the color of a pixel like (0,255,0).
I have written the class but I have a null point exception on two of my methods.
- getWidth
- toGrayscaleArray
What interesting is that the method getHight doesn't throw that error.
   public class RGBImage{
   private RGBColor[][] _image;
    final RGBColor DEFAULT_COLOR_VALUE = new RGBColor(0,0,0);
    public RGBImage(int rows, int cols) {
        RGBColor[][] _image = new RGBColor[rows][cols];
    }
    public int getHeight(){
        int output = _image[0].length;
        return output;
    }
    public int getWidth(){
        int output = _image.length;
        return output;
    }
    public double[][] toGrayscaleArray(){
        double output[][] = new double[_image.length][_image[0].length];
        
        for (int i = 0; i < _image.length; i++){
            for (int j = 0; j < _image[0].length; j++){
                output[i][j] = _image[i][j].convertToGrayscale();// this is a method from the RGBColor class
            }
        }
        
        return output;
    }
   }
