fixed major median 0 bug in reference image processing