Archive for January 23, 2022

Fun numpy things

Diff two images

diff_image = abs(prediction_mask - true_mask)

Count pixels that exactly match between two images

diff_image = abs(prediction_mask - true_mask)
matches = 1.0 * (diff_image == 0)
matches_count = np.sum(matches)

Count prediction pixels that do not match truth-mask pixels

diff_image = abs(prediction_mask - true_mask)
unpaired_pred_msk  = 1.0 * (prediction_mask>0) * (diff_img>0)       
un_matched_pred_count = np.sum(unpaired_pred_msk)

Comments off