Skip to content

Commit

Permalink
Hakka pantie converter Ver. 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TenteEEEE committed Aug 22, 2020
1 parent c58f746 commit 0d2ecba
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
Binary file added body/body_hakka.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mask/mask_hakka_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mask/mask_hakka_front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@
|![test](./sample/chiharu_pantie.png)|![test](./sample/lopolykon_pantie.png)|
|[マロン](https://booth.pm/ja/items/1105063)ちゃん|[リアアリス](https://booth.pm/ja/items/2146588)ちゃん|
|![test](./sample/marron_pantie.png)|![test](./sample/rearalice_pantie.png)|
|[式神(零)](https://booth.pm/ja/items/2033949)|[ミラ](https://booth.pm/ja/items/2140459)|
|[式神(零)](https://booth.pm/ja/items/2033949)ちゃん|[ミラ](https://booth.pm/ja/items/2140459)ちゃん|
|![test](./sample/rei_pantie.png)|![test](./sample/mira_pantie.png)|
|[薄荷](https://booth.pm/ja/items/2215270)ちゃん||
|![test](./sample/hakka_pantie.png)||

## スペシャルサンクス
[Booth:キッシュちゃん](https://mutachannel.booth.pm/items/954376)
Expand Down Expand Up @@ -190,6 +192,8 @@ When you want to know the help, please run `python patch.py -h`
|![test](./sample/marron_pantie.png)|![test](./sample/rearalice_pantie.png)|
|[Rei](https://booth.pm/ja/items/2033949)|[Mira](https://booth.pm/ja/items/2140459)|
|![test](./sample/rei_pantie.png)|![test](./sample/mira_pantie.png)|
|[Hakka](https://booth.pm/ja/items/2215270)||
|![test](./sample/hakka_pantie.png)||

## Special thanks
[Quiche model](https://mutachannel.booth.pm/items/954376)
Expand Down
Binary file added sample/hakka_pantie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions src/models/hakka.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import skimage.io as io
import skimage.transform as skt
import numpy as np
from PIL import Image
from src.models.class_patcher import patcher
from src.utils.imgproc import *


class patcher(patcher):
def __init__(self, body='./body/body_hakka.png', **options):
super().__init__('薄荷', body=body, pantie_position=[0, 0], **options)
self.mask_front = io.imread('./mask/mask_hakka_front.png')
self.mask_back = io.imread('./mask/mask_hakka_back.png')

def convert_front(self, image):
pantie = np.array(image)
patch = np.copy(pantie[-120:-5, 546:, :])
[pr, pc, d] = patch.shape
pantie[125:125 + pr, :pc, :] = patch[::-1, ::-1]
front = pantie[:, :330]
arrx = np.zeros(64)
arrx[20:] += np.sin(np.linspace(0, np.pi / 2, 44)) * 79
arrx[10:20] += np.sin(np.linspace(0, np.pi, 10)) * 8
arrx -= 80
arry = np.zeros(64)
front = affine_transform_by_arr(front, arrx, arry)[:320]
front = np.uint8(resize(front, [1.2, 1.12]) * 255)[:, 8:]
front = np.bitwise_and(front, self.mask_front)
front = np.concatenate([front[:, ::-1], front], axis=1)
return Image.fromarray(front)

def convert_back(self, image):
pantie = np.array(image)
pantie[-120:, 546:, :] = 0
back = np.rot90(pantie[:-15, 330:][:, ::-1])
arrx = np.zeros(36)
arry = np.zeros(36)
arry[5:-5] = np.sin(np.linspace(0, np.pi, 26))**2 * 50
arry -= 30
back = affine_transform_by_arr(back, arrx, arry)
back = np.rot90(back, -1)
arrx = np.zeros(64)
arrx[6:] = np.linspace(0, np.pi / 2, 58)**2 * 43
arrx[45:55] += np.sin(np.linspace(0, np.pi, 10)) * 4
arrx -= 80
arry = np.zeros(64)
back = affine_transform_by_arr(back, arrx, arry)[:320]
back = np.uint8(resize(back, [1.2, 1.12]) * 255)[:, 18:]
back = np.bitwise_and(back, self.mask_back)
back = np.concatenate([back[:, ::-1], back], axis=1)
return Image.fromarray(back)

def patch(self, image, transparent=False):
pantie = self.convert(image)
if transparent:
patched = Image.new("RGBA", self.body_size)
else:
patched = self.body.copy()
patched = self.paste(patched, self.convert_front(image), (2180, 1671))
patched = self.paste(patched, self.convert_back(image), (2907, 1647))
return patched

0 comments on commit 0d2ecba

Please sign in to comment.