Michael Lee Posted September 19, 2021 Share Posted September 19, 2021 One of the disadvantage of the first variation I tried was that the resizing is naturally tied to the grid of pixels of the image. Therefore, I figured out a similar idea without this artifact. Although the pictures (with pseudorandom noise) are not quite as cool, it does have a very "fractally" nature to it. #--------------------------------- # Original author: Michael S. Lee # Date: 9/18/2021 #--------------------------------- import numpy as np import imageio import cv2 from scipy.signal import convolve,get_window import matplotlib.pyplot as plt def shrink(x, gamma = 30): beta = gamma / (x.std()) y = 1.0 / (1.0 + np.exp(-beta*(x-x.mean()))) return(y) N = 1024 # Image size noise = np.random.rand(N,N,3) # White noise in RGB channels noise2 = np.copy(noise) # setup output array noise2 = cv2.resize(noise2,(1024,1024)) noise2 = noise image = noise2 blur = np.copy(image) sum1 = np.zeros_like(image) thresh = 0.375 i = 1024 num_levels = 19 factor = 3/4 for j in range(num_levels): blur2 = blur ii = ((i+1) // 2) * 2 blur = cv2.GaussianBlur(noise2, (ii-1,ii-1), 0) #convolve(noise2,kernel3,'same') if (j > 0): diff = blur - blur2 diff = shrink(diff, gamma = 25) sum1 = sum1 + (i**0.25)*diff #sum1 = sum1 + diff print (i) i = int(i * factor) sum1 = (sum1 - sum1.min())/ (sum1.max()-sum1.min()) sum1 = sum1 ** 3 # Save on disk index = np.random.randint(0,262144) # Random filename imageio.imsave('temp.'+str(index)+'.png',sum1) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.