Created
January 4, 2020 13:01
-
-
Save lucifermorningstar1305/e5cfd34c84ff3143bc35395027d7c1c6 to your computer and use it in GitHub Desktop.
Gaussian Filter algorithm
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
Hg = np.zeros((20,20)) | |
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) | |
for i in range(20): | |
for j in range(20): | |
Hg[i,j] = np.exp(-((i-10) ** 2 + (j-10)**2)/10) | |
gaussian_blur = scipy.signal.convolve2d(gray, Hg, mode='same') | |
gray_high = gray - gaussian_blur | |
gray_enhanced = gray + 0.025 * gray_high | |
imgs = np.array([ gray, gaussian_blur, gray_high, gray_enhanced]) | |
labels = ['Original', 'Filtered', 'High Components', 'Enhanced'] | |
for i in range(1, column*row+1): | |
ax = fig.add_subplot(row,column,i) | |
ax.set_title(labels[i-1]) | |
plt.imshow(imgs[i-1], cmap='gray') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment