@@ -0,0 +1,1453 @@
+package nl.fifth.postulate.bin;%0A%0Aimport nom.tam.fits.BinaryTableHDU;%0Aimport nom.tam.fits.Fits;%0Aimport nom.tam.fits.FitsException;%0A%0Aimport java.io.*;%0A%0Apublic class Average %7B%0A    public static void main(String%5B%5D args) throws FitsException, IOException %7B%0A        String filename = args%5B0%5D;%0A        String pathName = args%5B1%5D;%0A%0A        PrintStream output = new PrintStream(new FileOutputStream(pathName));%0A%0A%0A        float%5B%5D average = calculateAverage(filename);%0A%0A        for (int index = 0, limit = average.length; index %3C limit; index++) %7B%0A            output.printf(%22%254d, %25f%5Cn%22, index, average%5Bindex%5D);%0A        %7D%0A%0A    %7D%0A%0A    private static float%5B%5D calculateAverage(String filename) throws FitsException, IOException %7B%0A        Fits f = new Fits(filename);%0A        BinaryTableHDU hdu = (BinaryTableHDU) f.getHDU(1);%0A        float%5B%5D%5B%5D%5B%5D rows = (float%5B%5D%5B%5D%5B%5D) hdu.getColumn(%22FLUX%22);%0A%0A        float%5B%5D average = new float%5Brows.length%5D;%0A        for (int row = 0, rowLimit = rows.length; row %3C rowLimit; row++ ) %7B%0A            float sum = 0.0f;%0A            int count = 0;%0A            float%5B%5D%5B%5D inputImage = rows%5Brow%5D;%0A            for (int y = 0, ylimit = inputImage.length; y %3C ylimit; y++) %7B%0A                for (int x = 0, xlimit = inputImage%5B0%5D.length; x %3C xlimit; x++) %7B%0A                    sum += inputImage%5By%5D%5Bx%5D;%0A                    count += 1;%0A                %7D%0A            %7D%0A            average%5Brow%5D = sum / count;%0A        %7D%0A%0A        return average;%0A    %7D%0A%7D%0A

Calculate the average