Last active
September 18, 2020 13:41
-
-
Save sansuke05/86744543be6bbe2cefe763518083ca8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mask = io.imread('./mask/mask_cynthia.png') | |
def convert_cynthia_pantie(image): | |
pantie = np.array(image) | |
patch = np.copy(pantie[-100:-5, 546:, :]) | |
pantie[-100:, 546:, :] = 0 | |
patch = skt.resize(patch[::-1, ::-1, :], | |
(patch.shape[0] + 30, patch.shape[1]), | |
anti_aliasing=True, | |
mode='reflect') | |
# パッチを元のパンツに貼りつけ | |
[pr, pc, d] = patch.shape | |
pantie[127 - 5:127 - 5 + pr, :pc, :] = np.uint8(patch * 255) | |
# フロント部分だけ切り出し | |
front = pantie[:350 - 105, 7:300] | |
# バック部分の切り出しと左右反転 | |
back = pantie[:350, 300:-10][:, ::-1] | |
# バック部分を形に合わせて変形 | |
arrx = (np.linspace(0, 1, 25)**2) * 115 | |
arrx[2:14] += np.sin(np.linspace(0, np.pi, 12)) * 7 | |
arry = (np.linspace(0, 1, 25)**2) * 115 | |
arrx -= 60 | |
back = affine_transform_by_arr(back, arrx, arry) | |
# バック部分を上下反転 | |
back = np.uint8(back[::-1, 7:] * 255) | |
back = back[3:, 10:10 + front.shape[1]] | |
# フロントとバックを結合、調整 | |
pantie = np.concatenate((front, back), axis=0) | |
pantie = np.uint8(resize(pantie, [0.789, 0.878]) * 255) | |
pantie = np.bitwise_and(pantie, mask) | |
pantie = np.concatenate((pantie[:, ::-1], pantie), axis=1) | |
return Image.fromarray(pantie) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
正面の裾付近は少し大きめに貼り、マスクで切り取ってしまうのが最もかんたんです。
ただ、20番前後ぐらいまではパンツパッチ純対応パンツではないということもあり、30番以降ぐらいに対応を絞っても良いと思います。
後ろはだいたい合わせたのですが、ここから微調整すれば形は合うと思います。
![a](https://user-images.githubusercontent.com/9051681/93603789-73067080-f9ff-11ea-86f2-ad28280764c4.png)