          outimage = cv2.add(foreground, background)
  
          return outimage
  
      def cal_crop(self, src, desc, centerx, centery):
          crop = False
          
          src_w = src.shape[1]
          src_h = src.shape[0]
          desc_w = desc.shape[1]
          desc_h = desc.shape[0]
          
          w_left = src_w // 2 - 1
          h_up = src_h // 2 - 1
          w_right = src_w - w_left
          h_down = src_h - h_up
          
          
          xmin = 0
          ymin = 0
          xmax = src_w-1
          ymax = src_h-1
          
          cxshift = 0 
          cyshift = 0
          
          if centerx - w_left < 0:
              crop = True
              xmin = - (centerx - w_left)
              cxshift = cxshift + (centerx - w_left)//2
              
          if centery - h_up < 0:
              crop = True
              ymin = - (centery - h_up)
              cyshift = cyshift + (centery - h_up)//2
          
          if centerx + w_right > desc_w - 1:
              crop = True
              xmax = xmax - ((centerx + w_right) - (desc_w - 1))
              cxshift = cxshift + ((centerx + w_right) - (desc_w - 1))//2
              
          if centery + h_down > desc_h - 1:
              crop = True
              ymax = ymax - ((centery + h_down) - (desc_h - 1))
              cyshift = cyshift + ((centery + h_down) - (desc_h - 1))//2
          
      
          return crop, xmin, xmax, ymin, ymax, cxshift, cyshift
  
      def hist_match(self, source, template, mask=None):
          # Code borrowed from:
          # https://stackoverflow.com/questions/32655686/histogram-matching-of-two-images-in-python-2-x
          masked_source = source
          masked_template = template
 
</s> remove                 maskx = int(minx + (lenx // 2))
                masky = int(miny + (leny // 2))
                
                crop, xmin, xmax, ymin, ymax, cx, cy = self.cal_crop(new_image, 
                                                                     base_image, 
                                                                     maskx, 
                                                                     masky)
                if crop:
                    new_image = new_image[ymin:ymax+1, xmin:xmax+1]
                    unitMask = unitMask[ymin:ymax+1, xmin:xmax+1]
                    maskx = maskx - cx
                    masky = masky - cy
                
 </s> add                 masky = int(minx + (lenx // 2))
                maskx = int(miny + (leny // 2))
 </s> remove                                              (maskx, masky),
 </s> add                                              (masky, maskx),

          outimage = cv2.add(foreground, background)
  
          return outimage
  













































      def hist_match(self, source, template, mask=None):
          # Code borrowed from:
          # https://stackoverflow.com/questions/32655686/histogram-matching-of-two-images-in-python-2-x
          masked_source = source
          masked_template = template
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Revert "attempted fix of a crash in apply_new_face function (#586)" (#589)

This reverts commit 3aeb358f44ea7264acd9d05677ea2c6e98e9d9da. 
plugins/convert/Convert_Masked.py