Question
Using the given images and example codes (Given Below); Add your own Haar wavelet Add 4th order Daubechies wavelet Add Antonini-Barlaud-Mathieu-Daubechies wavelet (check your book/slides)
Using the given images and example codes (Given Below);
Add your own Haar wavelet
Add 4th order Daubechies wavelet
Add Antonini-Barlaud-Mathieu-Daubechies wavelet (check your book/slides)
try a wavefilter you choose with one of the wavelet processed images.()
plot them seperately
This time you need to explain wavelets and wavefilters using your own words. What happend when you used them? What are the differences? If you have used different resources please add them as references.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Images and Example Codes:
code1: edges.py: # import cv2 # cap = cv2.VideoCapture(0) # while True: # ret, img = cap.read() # gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # blur = cv2.GaussianBlur(gray, (5, 5), 0) # canny = cv2.Canny(blur, 10, 70) # ret, mask = cv2.threshold(canny, 70, 255, cv2.THRESH_BINARY) # cv2.imshow('Video feed', mask) # if cv2.waitKey(1) == 13: # break # cap.release() # cv2.destroyAllWindows()
""" """ # import cv2 # from matplotlib import pyplot as plt # # read image for edge detection # img = cv2.imread("cameraman.tif") # b,g,r = cv2.split(img) # img = cv2.merge([r,g,b]) # # detect edges from img # edges = cv2.Canny(img, 100, 200) # # create subplot to display # # original image # plt.subplot(1, 2, 1) # plt.imshow(img, cmap="gray") # # set the title for original # # image # plt.title("Original Image") # plt.axis("off") # # create subplot to display # # edge detected image # plt.subplot(1, 2, 2) # plt.imshow(edges, cmap="gray") # # set the title for edge # # detected image # plt.title("Edge Detection") # plt.axis("off") # # diplay the plotted images # plt.show() # """ # """ # import cv2 # import matplotlib.pyplot as plt
# def detect_edge(image): # ''' function Detecting Edges ''' # image_with_edges = cv2.Canny(image , 100, 200) # images = [image , image_with_edges] # location = [121, 122] # for loc, img in zip(location, images): # plt.subplot(loc) # plt.imshow(img, cmap='gray') # plt.savefig('edge.png') # plt.show() # image = cv2.imread('road.jpg', 0) # detect_edge(image)
# """ # """ from PIL import Image, ImageFilter img = Image.open(r"catLena.png") # Converting the image to grayscale, as Sobel Operator requires # input image to be of mode Grayscale (L) img = img.convert("L") # Calculating Edges using the passed laplican Kernel final = img.filter(ImageFilter.Kernel((3, 3), (0, -2, 0, -2, 11, -2, 0, -2, 0), 1, 0)) final.save("EDGE_sample.png")
""" """
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code 2: edge2.py
import cv2 as cv import numpy as np
#load birds image image = cv.imread("cameraman.tif")
#convert to gray image gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
#detect sobel gradients sobel_x_edges = cv.Sobel(gray_image, cv.CV_64F,1, 0) sobel_y_edges = cv.Sobel(gray_image, cv.CV_64F,0, 1)
#convert all -ve pixels to positives sobel_x_edges = np.uint8(np.absolute(sobel_x_edges)) sobel_y_edges = np.uint8(np.absolute(sobel_y_edges))
#show images cv.imshow("Sobel X Edges", sobel_x_edges) cv.imshow("Sobel y Edges", sobel_y_edges)
cv.waitKey(0)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code 3: wavelett
Deleted because it was so long
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
code 4: wavelett2:
import matplotlib.pyplot as plt
from skimage.restoration import (denoise_tv_chambolle, denoise_bilateral, denoise_wavelet, estimate_sigma) from skimage import data, img_as_float from skimage.util import random_noise
original = img_as_float(data.chelsea()[100:250, 50:300])
sigma = 0.155 noisy = random_noise(original, var=sigma**2)
fig, ax = plt.subplots(nrows=2, ncols=4, figsize=(8, 5), sharex=True, sharey=True)
plt.gray()
# Estimate the average noise standard deviation across color channels. sigma_est = estimate_sigma(noisy, average_sigmas=True) # Due to clipping in random_noise, the estimate will be a bit smaller than the # specified sigma. print(f'Estimated Gaussian noise standard deviation = {sigma_est}')
ax[0, 0].imshow(noisy) ax[0, 0].axis('off') ax[0, 0].set_title('Noisy') ax[0, 1].imshow(denoise_tv_chambolle(noisy, weight=0.1)) ax[0, 1].axis('off') ax[0, 1].set_title('TV') ax[0, 2].imshow(denoise_bilateral(noisy, sigma_color=0.07, sigma_spatial=7,multichannel=True))
ax[0, 2].axis('off') ax[0, 2].set_title('Bilateral') ax[0, 3].imshow(denoise_wavelet(noisy, multichannel=True, rescale_sigma=True)) ax[0, 3].axis('off') ax[0, 3].set_title('Wavelet denoising')
ax[1, 1].imshow(denoise_tv_chambolle(noisy, weight=0.2)) ax[1, 1].axis('off') ax[1, 1].set_title('(more) TV') ax[1, 2].imshow(denoise_bilateral(noisy, sigma_color=0.1, sigma_spatial=15, multichannel=True)) ax[1, 2].axis('off') ax[1, 2].set_title('(more) Bilateral') ax[1, 3].imshow(denoise_wavelet(noisy, multichannel=True, convert2ycbcr=True, rescale_sigma=True)) ax[1, 3].axis('off') ax[1, 3].set_title('Wavelet denoising in YCbCr colorspace') ax[1, 0].imshow(original) ax[1, 0].axis('off') ax[1, 0].set_title('Original') fig.tight_layout() plt.show()
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code 5: wavelett3:
import numpy as np import matplotlib.pyplot as plt
import pywt import pywt.data
# Load image original = pywt.data.camera()
# Wavelet transform of image, and plot approximation and details titles = ['Approximation', ' Horizontal detail', 'Vertical detail', 'Diagonal detail'] coeffs2 = pywt.dwt2(original, 'bior1.3') LL, (LH, HL, HH) = coeffs2 fig = plt.figure(figsize=(12, 3)) for i, a in enumerate([LL, LH, HL, HH]): ax = fig.add_subplot(1, 4, i + 1) ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) ax.set_title(titles[i], fontsize=10) ax.set_xticks([]) ax.set_yticks([])
fig.tight_layout() plt.show()
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Example Image:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started