Calculate True Positive, False Positive, True Negative and False negative and colourize output
Don't use manual iteration. It's slow and tedious. Use broadcasting instead. 

For instance, you can create a true positives mask like this:

true_positive_mask = np.logical_and(prediction &gt; 127, truth_image &gt; 127)

After that, you can use this mask to index the output image:

output_image[true_positive_mask] = green # or whatever color you want

and to compute the total number of true positives:

true_positives = np.sum(true_positive_mask)

You can use the same idea to compute other values or for input binarization.