Code:
from skimage import data, io, util
import random
import sys
from skimage.color import rgb2gray
try:
rgb_image = data.imread(sys.argv[1])
height = rgb_image.shape[0]
width = rgb_image.shape[1]
if(len(rgb_image.shape) == 3):
rgb_image = util.img_as_ubyte(rgb2gray(rgb_image))
for i in range(height):
for j in range(width):
if rgb_image[i,j] < 128:
rgb_image[i,j] = 15
else:
rgb_image[i,j] = 240
io.imsave("pencil_sketch.jpg", rgb_image)
except Exception as e:
print(e)
Original Image (RGB):
Pencil Sketch:
Original Image (Grayscale):
Pencil Sketch:
from skimage import data, io, util
import random
import sys
from skimage.color import rgb2gray
try:
rgb_image = data.imread(sys.argv[1])
height = rgb_image.shape[0]
width = rgb_image.shape[1]
if(len(rgb_image.shape) == 3):
rgb_image = util.img_as_ubyte(rgb2gray(rgb_image))
for i in range(height):
for j in range(width):
if rgb_image[i,j] < 128:
rgb_image[i,j] = 15
else:
rgb_image[i,j] = 240
io.imsave("pencil_sketch.jpg", rgb_image)
except Exception as e:
print(e)
Original Image (RGB):
Pencil Sketch:
Original Image (Grayscale):
Pencil Sketch:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.