Created
March 2, 2019 19:11
-
-
Save arifullahjan/74e6078f70d713f7088bb9cea9305e27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
python task1.py path/to/input threshold-int | |
''' | |
import PIL | |
from PIL import Image | |
import itertools | |
import sys | |
from PIL import ImageDraw | |
image = Image.open(sys.argv[1]) | |
image = image.convert("L") # convert to signle channeled image | |
width, height = image.size | |
pixels = image.load() # allows pixel values to be edited | |
for x,y in itertools.product(range(width), range(height)): # all possible values of x and y | |
if pixels[x,y] > int(sys.argv[2]): | |
pixels[x,y] = 255 | |
else: | |
pixels[x,y] = 0 | |
image.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment