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
#read in the image | |
img = plt.imread('penguin.jpg') | |
#convert image to grayscale | |
greyImg = np.mean(img, axis=2).astype(np.uint8) | |
#the edge kernel, when convolved with our image, detects the edges | |
edge_kernel = np.array([[0,1,0],[1,-4,1],[0,1,0]]) | |
#convolve edge kernel with image |
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
#define the ticker symbol | |
tickerSymbol = 'MSFT' | |
#get data on this ticker | |
tickerData = yf.Ticker(tickerSymbol) | |
#get recommendation data for ticker | |
tickerData.recommendations |
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
#define the ticker symbol | |
tickerSymbol = 'MSFT' | |
#get data on this ticker | |
tickerData = yf.Ticker(tickerSymbol) | |
#get event data for ticker | |
tickerData.calendar |
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
#define the ticker symbol | |
tickerSymbol = 'MSFT' | |
#get data on this ticker | |
tickerData = yf.Ticker(tickerSymbol) | |
#info on the company | |
tickerData.info |
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
import yfinance as yf | |
#define the ticker symbol | |
tickerSymbol = 'MSFT' | |
#get data on this ticker | |
tickerData = yf.Ticker(tickerSymbol) | |
#get the historical prices for this ticker | |
tickerDf = tickerData.history(period='1d', start='2010-1-1', end='2020-1-25') |
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
%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
#define the vertical filter | |
vertical_filter = [[-1,-2,-1], [0,0,0], [1,2,1]] | |
#define the horizontal filter | |
horizontal_filter = [[-1,0,1], [-2,0,2], [-1,0,1]] |
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
%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
#define the vertical filter | |
vertical_filter = [[-1,-2,-1], [0,0,0], [1,2,1]] | |
#define the horizontal filter | |
horizontal_filter = [[-1,0,1], [-2,0,2], [-1,0,1]] |
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
#set the intensity of the halo | |
intensity = 250.0 | |
#create a noramlizing constant so the halo fully fades out at the corners | |
denominator = intensity/((n/2)**2 + (m/2)**2) | |
#get the normalized squared distances of each pixel from the center | |
squared_distances = ((x-center_x)**2 + (y-center_y)**2)*denominator | |
#reshape this 2D matrix into a 3D matrix |
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
#operate on a copy | |
copyImg = img.copy() | |
#rotating an image 90 degrees CCW is like mapping the pixel at (x,y) to the pixel at (y,-x) | |
copyImg = img[y,-x] | |
#show image | |
plt.imshow(copyImg) |
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
#get the dimensions of the image | |
n,m,d = img.shape | |
#create an open grid for our image | |
x,y = np.ogrid[0:n, 0:m] |
NewerOlder