Sorry for the vague title it's 3:30 in the morning and I really want to get this done.
My problem is that I am adding together two integers and dividing by two to find the average of them.
Because the numbers are between 0 and 255 I will sometimes end up with a '.5' on the end which of course my compiler doesn't like.
Is there a method for removing such occurrences? If not, how would I got about getting around this problem.
Quick note, no I can't just declare a double instead as I am passed an array of Int's to work with.
Here is my code for reference
public void mergeImage(){ int [][] other = this.loadImage(UIFileChooser.open()); int rows = Math.min(this.image.length, other.length); int cols = Math.min(this.image[0].length, other[0].length); for(int i = 0; i < rows-1; i++){ for (int ii = 0; ii < cols-1; ii++){ int a = this.image[rows][cols]; int b = other[rows][cols]; this.image[rows][cols] = (a+b)/2; } } }