-
-
Save shivamanhar/44605535fe5c77157380b627da2a9616 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
#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 | |
squared_distances = squared_distances.reshape(n,m,1) | |
#"stack" three copies of this 3D matrix to create a numpy array with the same dims as our image | |
stacked_squared_dists = np.concatenate([squared_distances]*3, axis=2) | |
#create an edited image by adding our original image to our halo | |
editedImg = img + stacked_squared_dists | |
#recast the edited image to integers | |
editedImg = editedImg.astype(int) | |
#show image | |
plt.imshow(editedImg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment