コード例 #1
0
ファイル: pil_example.py プロジェクト: reshalfahsi/ggb
def main():
    # Load image from internet
    req = urllib.urlopen('https://github.com/reshalfahsi/GGB/raw/master/docs/img/leukocytes.png')
    arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
    img = cv2.imdecode(arr, -1)
    # Converting to GGB Color
    img = Image.fromarray(img)
    ggb_image = GGB(image=img, input_color=ColorSpace.BGR).process()
    ggb_image.show()

    # Result
    img = ggb_image.write()
    img.show()
コード例 #2
0
ファイル: __main__.py プロジェクト: reshalfahsi/ggb
def main(
    image: str,
    output: str,
) -> None:
    img = None

    try:
        req = urllib.urlopen(image)
        arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
        img = cv2.imdecode(arr, -1)
    except:
        img = cv2.imread(image)

    ggb_image = GGB(image=img, input_color=ColorSpace.BGR).process()
    ggb_image.write(output)
    print("The GGB image is written to {}".format(output))
コード例 #3
0
def test_pil_backend():
    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    image = get_random_image(w, h, 3, CVLib.PIL)

    ggb_image = GGB(image=image).process()
    assert (ggb_image.backend() == CVLib.PIL)

    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    value = random.randint(0, 255)
    image = get_filled_image(w, h, 3, value, CVLib.PIL)

    ggb_image = GGB(image=image).process()
    assert (ggb_image.backend() == CVLib.PIL)
コード例 #4
0
ファイル: test_write.py プロジェクト: reshalfahsi/ggb
def test_pil_write():
    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    image = get_random_image(w, h, 3, CVLib.PIL)

    ggb_image = GGB(image=image).process()
    assert(isinstance(ggb_image.write(), Image.Image))

    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    value = random.randint(0, 255)
    image = get_filled_image(w, h, 3, value, CVLib.PIL)

    ggb_image = GGB(image=image).process()
    assert(isinstance(ggb_image.write(), Image.Image))
コード例 #5
0
ファイル: test_write.py プロジェクト: reshalfahsi/ggb
def test_opencv_write():
    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    image = get_random_image(w, h, 3, CVLib.OPENCV)

    ggb_image = GGB(image=image).process()
    assert(isinstance(ggb_image.write(), np.ndarray))

    w = random.randint(16, 2048)
    h = random.randint(16, 2048)
    value = random.randint(0, 255)
    image = get_filled_image(w, h, 3, value, CVLib.OPENCV)

    ggb_image = GGB(image=image).process()
    assert(isinstance(ggb_image.write(), np.ndarray))