def calc_hist_from_fore(self, img, img_fore): hist = Histogram() hist.calc(img, user_mask = img_fore) back_proj = calc_back_proj(img, hist.hist) back_proj &= img_fore cv2.imwrite('img_back_%03d.png' % self.depth_frame_cnt, back_proj)