Posts

Edit photo - Picture frame - Image effects in Python

Image
from skimage import data, io import sys from skimage.color import gray2rgb 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 = gray2rgb(rgb_image)         for i,j in zip(range(int(width/8)), range(int(width/8),0,-1)):         rgb_image[i, 0:j, :] = 0         for i,j in zip(range(int(7*(height/8)),height), range(0,int(width/8))):         rgb_image[i, 0:j, :] = 0    

Edit photo - Square crop - Image resizing in Python

Image
from skimage import data, io import sys from skimage.color import gray2rgb try:     rgb_image = data.imread(sys.argv[1])     height = rgb_image.shape[0]     width = rgb_image.shape[1]     if height == width:         print("already square image")         else:         if(len(rgb_image.shape) < 3):             rgb_image = gray2rgb(rgb_image)                     right_image = rgb_image.copy()         left_image = rgb_image.copy()         center_image = rgb_image.copy()        

Edit photo - Oil painting effect - Image manipulation in Python

Image
from skimage import data, io import random import sys from skimage.color import gray2rgb 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 = gray2rgb(rgb_image)         for i in range(height):         for j in range(width):             for k in range(rgb_image.shape[2]):

Edit photo - Pencil sketch effect - Image processing in Python

Image
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))

Python: Count occurences in List

Image
1. Histogram >>> mylist = [1,3,2,5,4,4,2,2,4,2,4,2,4,6,4,5,2] >>> import matplotlib.pyplot as plt >>> plt.hist(mylist) (array([ 1.,  0.,  6.,  0.,  1.,  0.,  6.,  0.,  2.,  1.]), array([ 1. ,  1.5,  2. ,  2.5,  3. ,  3.5,  4. ,  4.5,  5. ,  5.5,  6. ]), <a list of 10 Patch objects>) >>> plt.show()