                  np.clip(masked, 0.0, 255.0, out=masked)
                  diff = frame - masked
                  avg_diff = np.sum(diff * image_mask, axis=(0, 1))
                  adjustment = avg_diff / np.sum(image_mask, axis=(0, 1))
                  masked = masked + adjustment
  
          if self.args.match_histogram:
              np.clip(masked, 0.0, 255.0, out=masked)
              masked = self.color_hist_match(masked, frame, image_mask)
  
 
</s> remove                 np.clip(masked, 0.0, 255.0, out=masked)
                diff = frame - masked
 </s> add                 np.clip(new_image, 0.0, 255.0, out=new_image)
                diff = frame - new_image </s> remove             np.clip(masked, 0.0, 255.0, out=masked)
            masked = self.color_hist_match(masked, frame, image_mask)
 </s> add             np.clip(new_image, 0.0, 255.0, out=new_image)
            new_image = self.color_hist_match(new_image, frame, image_mask) </s> remove                                          masked)
 </s> add                                          new_image) </s> remove         masked = new_image  # * image_mask
 </s> add  </s> remove             foreground = masked * image_mask
 </s> add             foreground = new_image * image_mask
                new_image = new_image + adjustment
                  np.clip(masked, 0.0, 255.0, out=masked)
                  diff = frame - masked
                  avg_diff = np.sum(diff * image_mask, axis=(0, 1))
                  adjustment = avg_diff / np.sum(image_mask, axis=(0, 1))
                new_image = new_image + adjustment
  
          if self.args.match_histogram:
              np.clip(masked, 0.0, 255.0, out=masked)
              masked = self.color_hist_match(masked, frame, image_mask)
  
keep keep keep keep replace keep keep keep keep keep
 auto smooth edges size and clarify naming 
plugins/convert/masked.py