No account yet ?
Multiscale image contrast amplification using Laplacian pyramid
Copyright (C) 2007 Free Software Foundation, Inc.
A contrast enhancement approach involving non linear mapping of Laplacian pyramid - GitHub
Tested in Anaconda and Python 3.7
# -*- coding: utf-8 -*- """ Created on Fri Jun 24 14:24:07 2022 @author: https://theailearner.com/tag/laplacian-pyramid-opencv/ """ import cv2 from matplotlib import pyplot as plt def showimage(myimage, figsize=[10,10]): if (myimage.ndim>2): #This only applies to RGB or RGBA images (e.g. not to Black and White images) myimage = myimage[:,:,::-1] #OpenCV follows BGR order, while matplotlib likely follows RGB order fig, ax = plt.subplots(figsize=figsize) ax.imshow(myimage, cmap = 'gray', interpolation = 'bicubic') plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis plt.show() # Load the grayscale image img = cv2.imread('lena.jpg',0) lower = img.copy() # Create a Gaussian Pyramid gaussian_pyr = [lower] for i in range(5): lower = cv2.pyrDown(lower) gaussian_pyr.append(lower) # Last level of Gaussian remains same in Laplacian laplacian_top = gaussian_pyr[-1] # Create a Laplacian Pyramid laplacian_pyr = [laplacian_top] for i in range(5,0,-1): size = (gaussian_pyr[i - 1].shape[1], gaussian_pyr[i - 1].shape[0]) print(size) gaussian_expanded = cv2.pyrUp(gaussian_pyr[i], dstsize=size) laplacian = cv2.subtract(gaussian_pyr[i-1]*10, gaussian_expanded) laplacian_pyr.append(laplacian) showimage(laplacian)
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License