This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
A = np.zeros((256, 256, 3)) | |
for i in xrange(0, 255, 3): | |
A[i, :, 0] = 255*np.ones((1, A.shape[1])) | |
A[i+1, :, 1] = 255*np.ones((1, A.shape[1])) | |
A[i+2, :, 2] = 255*np.ones((1, A.shape[1])) | |
A = np.dstack((A[:, :, 0], A[:, :, 1], A[:, :, 2])) |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io | |
def contrast_stretching(A, c1, c2, c3, c4): | |
A = c1*np.tanh(c2*A - c3) + c4 | |
return A | |
A = io.imread('castle1.jpg', plugin='pil') |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io, img_as_float | |
def salt_and_pepper_noise_gray(A, d): | |
rows = np.shape(A)[0] | |
columns = np.shape(A)[1] | |
number_of_pixels = int(d*rows*columns) |
This file contains 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
from __future__ import division | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage import io, img_as_float | |
def median_filter(A, filter_size): | |
rows = np.shape(A)[0] | |
columns = np.shape(A)[1] | |
half_length = int((filter_size-1)/2) |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io,color, img_as_float | |
def brighten(A): | |
gamma = 0.4 | |
c = 255 | |
A = c*(A**gamma) | |
return A |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io, color, img_as_float | |
def histogram_equalization(A): | |
rows = A.shape[0] | |
columns = A.shape[1] | |
histogram, bin_edges = np.histogram(A, range=(0,1), bins=255) | |
c = (np.cumsum(histogram/np.max(histogram)))*255 |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io,color, img_as_float | |
def averaging_mask(A, mask_size): | |
rows = np.shape(A)[0] | |
columns = np.shape(A)[1] | |
half_length = int((mask_size-1)/2) |
This file contains 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
def histogram_equalization_point_transformation(A): | |
B = A.copy() | |
P1 = B[:, :, 0] | |
P2 = B[:, :, 1] | |
P3 = B[:, :, 2] | |
G = (np.sum(B * (1/3, 1/3, 1/3), axis=2))/255 | |
rows = G.shape[0] | |
columns = G.shape[1] | |
histogram, bin_edges = np.histogram(G.flatten(), range=(0, 1), bins=256) |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io, color, img_as_float | |
def histogram_equalization(A): | |
rows = A.shape[0] | |
columns = A.shape[1] | |
histogram, bin_edges = np.histogram(A.flatten(), range=(0, 1), bins=256) | |
histogram = histogram/np.max(histogram) |
This file contains 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
from __future__ import division | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from skimage import io, color, img_as_float | |
def histogram_equalization(A): | |
rows = A.shape[0] | |
columns = A.shape[1] | |
histogram, bin_edges = np.histogram(A.flatten(), range=(0, 1), bins=256) | |
histogram = histogram/np.max(histogram) |
OlderNewer