Example #1
0
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()
Example #2
0
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))
Example #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)
Example #4
0
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))
Example #5
0
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))