Beispiel #1
0
def test_for_images(show_hist=False):
    IMG_PATH = abspath(join(dirname(__file__), pardir, 'images'))
    print "3. TEST KODOWANIA OBRAZÓW\n"
    images = listdir(IMG_PATH)

    for idx, image in enumerate(images, start=1):
        print "   3.%d. %s\n" % (idx, image)
        data = read_image(join(IMG_PATH, image))
        diffed = differential_encoding(data)
        if show_hist:
            show_histogram(diffed, image)
        scaled = scale_to_positive(diffed)
        encode_and_print_stats(scaled, 8)

    print "\n=======================================================================\n"
Beispiel #2
0
def test_for_images(show_hist=False):
    IMG_PATH = abspath(join(dirname(__file__), pardir, 'images'))
    print "3. TEST KODOWANIA OBRAZÓW\n"
    images = listdir(IMG_PATH)

    for idx, image in enumerate(images, start=1):
        print "   3.%d. %s\n" % (idx, image)
        data = read_image(join(IMG_PATH, image))
        diffed = differential_encoding(data)
        if show_hist:
            show_histogram(diffed, image)
        scaled = scale_to_positive(diffed)
        encode_and_print_stats(scaled, 8)

    print "\n=======================================================================\n"
def update_histogram(figure):
    # Retrieve the image stored inside the figure
    enc_str = figure["layout"]["images"][0]["source"].split(";base64,")[-1]
    # Creates the PIL Image object from the b64 png encoding
    im_pil = drc.b64_to_pil(string=enc_str)

    return utils.show_histogram(im_pil)
Beispiel #4
0
def update_histogram(figure):
    # Retrieve the image stored inside the figure
    enc_str = figure['layout']['images'][0]['source'].split(';base64,')[-1]
    # Creates the PIL Image object from the b64 png encoding
    im_pil = drc.b64_to_pil(string=enc_str)

    return show_histogram(im_pil)
Beispiel #5
0
def test_for_sample_data(show_hist=False):
    print "2. TEST KODOWANIA SZTUCZNYCH CIĄGÓW DANYCH\n"
    numpy.random.seed(37)

    print "   2.1. Rozkład jednostajny\n"

    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        uniform_samples = normalize_to_byte(
            numpy.random.uniform(0., 256., size_kb * 1024))
        if show_hist:
            show_histogram(uniform_samples)
        encode_and_print_stats(uniform_samples, 8)

    print "   2.2. Rozkład normalny\n"
    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        normal_samples = normalize_to_byte(numpy.random.normal(
            128., 16., 1024))
        if show_hist:
            show_histogram(normal_samples)
        encode_and_print_stats(normal_samples, 8)

    print "   2.3. Rozkład Laplace'a\n"
    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        laplace_samples = normalize_to_byte(
            numpy.random.laplace(128., 16., 1024))
        if show_hist:
            show_histogram(laplace_samples)
        encode_and_print_stats(laplace_samples, 8)

    print "\n=======================================================================\n"
Beispiel #6
0
def test_for_sample_data(show_hist=False):
    print "2. TEST KODOWANIA SZTUCZNYCH CIĄGÓW DANYCH\n"
    numpy.random.seed(37)

    print "   2.1. Rozkład jednostajny\n"

    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        uniform_samples = normalize_to_byte(numpy.random.uniform(0., 256., size_kb*1024))
        if show_hist:
            show_histogram(uniform_samples)
        encode_and_print_stats(uniform_samples, 8)

    print "   2.2. Rozkład normalny\n"
    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        normal_samples = normalize_to_byte(numpy.random.normal(128., 16., 1024))
        if show_hist:
            show_histogram(normal_samples)
        encode_and_print_stats(normal_samples, 8)

    print "   2.3. Rozkład Laplace'a\n"
    for i, size_kb in enumerate([1, 128, 1024]):
        print "     %s. %dKB" % (chr(ord('a') + i), size_kb)
        laplace_samples = normalize_to_byte(numpy.random.laplace(128., 16., 1024))
        if show_hist:
            show_histogram(laplace_samples)
        encode_and_print_stats(laplace_samples, 8)

    print "\n=======================================================================\n"
Beispiel #7
0
from matplotlib import pyplot as plt
from skimage import exposure
from utils import show_image, show_histogram

chest_xray_img = plt.imread('images/chest_xray.png')

show_image(chest_xray_img, "Chest x-ray")
show_histogram(chest_xray_img.ravel())

chest_xray_img_eq = exposure.equalize_hist(chest_xray_img)
show_image(chest_xray_img_eq, 'Resulting image')