| 186 | |
| 187 | |
| 188 | def build_alpha_pyramid(color, alpha, dk=1.2): |
| 189 | pyramid = [] |
| 190 | current_premultiplied_color = color * alpha |
| 191 | current_alpha = alpha |
| 192 | |
| 193 | while True: |
| 194 | pyramid.append((current_premultiplied_color, current_alpha)) |
| 195 | |
| 196 | H, W, C = current_alpha.shape |
| 197 | if min(H, W) == 1: |
| 198 | break |
| 199 | |
| 200 | current_premultiplied_color = cv2.resize(current_premultiplied_color, (int(W / dk), int(H / dk)), interpolation=cv2.INTER_AREA) |
| 201 | current_alpha = cv2.resize(current_alpha, (int(W / dk), int(H / dk)), interpolation=cv2.INTER_AREA)[:, :, None] |
| 202 | return pyramid[::-1] |
| 203 | |
| 204 | |
| 205 | def pad_rgb(np_rgba_hwc_uint8): |