Exemple #1
0
    def _addWaterRandPos(self, sImg):
        # Random size, 15% ~ 30%
        # percent = 15.0 + random.randint(0, 15)
        percent = 100

        x1 = random.randint(0, self._tWidth - self._markWidth - 1)
        y1 = random.randint(0, self._tHeight - self._markHeight - 1)

        x2 = x1 + self._markWidth
        y2 = y1 + self._markHeight

        return ImageHelper.AddWaterWithImg(sImg, self._markImg, x1, y1, x2, y2)
Exemple #2
0
    def _addWaterRandPos(self, sImg, x, y):
        # Random size, 15% ~ 30%
        # percent = 15.0 + random.randint(0, 15)
        percent = random.randint(95, 105)
        width = int(self._markWidth * percent / 100)
        height = int(self._markHeight * percent / 100)

        x1 = x + random.randint(0, self._tWidth - width - 1)
        y1 = y + random.randint(0, self._tHeight - height - 1)

        x2 = x1 + width
        y2 = y1 + height

        return ImageHelper.AddWaterWithImg(sImg, self._markImg, x1, y1, x2, y2)
Exemple #3
0
    def _addWater(self, tmpImg, markImg):
        percent = random.randint(90, 110)

        [markWidth, markHeight] = markImg.size
        width = int(markWidth * percent / 100)
        height = int(markHeight * percent / 100)
        
        x1 = random.randint(0, self._width - width - 1)
        y1 = random.randint(0, self._height - height - 1)

        x2 = x1 + width
        y2 = y1 + height

        return ImageHelper.AddWaterWithImg(tmpImg, markImg, x1, y1, x2, y2)
Exemple #4
0
    def _addWaterRandPos(self, sImg):
        # Random size, 15% ~ 30%
        # percent = 15.0 + random.randint(0, 15)
        percent = 30
        
        # x1 start with 10 percent
        x1 = 10 + random.randint(0, 50)
        # y1 start with 10 percent
        y1 = 10 + random.randint(0, 50)

        x2 = x1 + percent
        y2 = y1 + self._markHeight * percent / self._markWidth

        x1 = x1 / 100.0
        y1 = y1 / 100.0
        x2 = x2 / 100.0
        y2 = y2 / 100.0
        return ImageHelper.AddWaterWithImg(sImg, self._markImg, x1, y1, x2, y2)
Exemple #5
0
import random
from src.data.img.ImageHelper import ImageHelper

img = Image.open("image/source/00013_lighthouse_1280x800.jpg")
img = img.convert("L")
width, height = img.size
height = int(405 * height / width)
width = 405
img = img.resize((width, height), Image.ANTIALIAS)
mark = Image.open("image/mark/taptap_small.png")
mWidth, mHeight = mark.size
x1 = random.randint(0, width - mWidth - 1)
y1 = random.randint(0, height - mHeight - 1)
x2 = x1 + mWidth
y2 = y1 + mHeight
img = ImageHelper.AddWaterWithImg(img, mark, x1, y1, x2, y2)

kernel = [[0, -1, 0], [-1, 4, -1], [0, -1, 0]]
imgData = numpy.array(img)
imgData = signal.convolve2d(imgData, kernel, mode='same')
imgData = (imgData - numpy.min(imgData))
imgData = imgData * 255.0 / numpy.max(imgData)
imgData = imgData.astype('uint8')
img = Image.fromarray(imgData, 'L')
img.show()

tWidth = 81
tHeight = 24
dWidth = int(tWidth / 3)
dHeight = int(tHeight / 3)
wNum = int(round((width - tWidth) / dWidth)) + 1