Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(10)  |  Call(10)  |  Derive(0)  |  Import(0)
Remove noise pixels

        def rmnoise(im, size=5, min_nbs=2):
    """
    Remove noise pixels
    """
    data = im.load()
    width, height = im.size
    for x in range(width):
        for y in range(height):
            if data[x, y] == 255:
                continue
            else:
                nbs = count_neighbors(data, width, height, x, y, size)
                if nbs < min_nbs:
                    data[x, y] = 255
    return im
        


src/c/r/crszu-HEAD/tests/test_exceptions.py   crszu(Download)
def test_invalid_size_error():
    """Test size invalid exception."""
    rmnoise.rmnoise(img, size=-1)
    rmnoise.rmnoise(img, size=0)
    rmnoise.rmnoise(img, size=2)
    rmnoise.rmnoise(img, size=200)
def test_size_type_error():
    """Test size type error exception."""
    rmnoise.rmnoise(img, size=6.27)
    rmnoise.rmnoise(img, size="omg")
    rmnoise.rmnoise(img, size=[1, 2, 3])