Jump to content

Recommended Posts

Posted

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.

 

temp.162870.thumb.png.119dfe0e12972a407277392082bc0512.png

temp.235736.thumb.png.446d51f1c6700ae4f2324dbf0b0824f5.png

 

#---------------------------------
# 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)

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.