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

Edit photo - Change color effects - Image filtering in Python

Image
Code:- from skimage import data, io import random try:     rgb_image = data.imread("Collage.jpg")     #print(rgb_image.shape)         red_image = rgb_image.copy()     green_image = rgb_image.copy()     blue_image = rgb_image.copy()         red_image[:, :, (1, 2)] = 0     io.imsave("red_output_image.jpg", red_image)         green_image[:, :, (0, 2)] = 0     io.imsave("green_output_image.jpg", green_image)         blue_image[:, :, (0, 1)] = 0     io.imsave("blue_output_image.jpg", blue_image)    

Bar plot in Python using Bokeh

Image
import pandas as pd from collections import Counter from datetime import datetime, timedelta from bokeh.charts import Bar, output_file, show from bokeh.models.layouts import Column import numpy as np try:     data = pd.read_csv('new.csv')     scan_col = Counter(data['Scan'])     values = list()     keys = list()         for s in scan_col.keys():         scan_time_total = datetime.strptime("00:00:00","%H:%M:%S")         scan_time_total = timedelta(hours=scan_time_total.hour, minutes=scan_time_total.minute, seconds=scan_time_total.second)