#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @Article Title : Fractal Pattern for Multiscale Digital Image Correlation Journal : Experimental Mechanics @Authors: R. FOUQUE Université de Toulouse, ICA, INSA-UPS-Mines Albi-ISAE-CNRS, Toulouse, France. DGA Aeronautical Systems, Balma, France. fouque@insa-toulouse.fr J.C. Passieux and J.N. Périé Université de Toulouse, ICA, INSA-UPS-Mines Albi-ISAE-CNRS, Toulouse, France. R. Bouclier Université de Toulouse, IMT, INSA-UT1-UT2-UT3-CNRS, Toulouse, France. Université de Toulouse, ICA, INSA-UPS-Mines Albi-ISAE-CNRS, Toulouse, France. """ import numpy as np import matplotlib.pyplot as plt from scipy.special import erf # ============================================================================= # USER-DEFINED SETTINGS # ============================================================================= N=256 #Number of pixels along each direction H = 1/22 #Hurst exponent seed = 2 #Seed for the random phase psi sigma_over_sigma_gl = 0.3 #Ratio of sigma over sigma_gl for the #redistribution process m = 255 #Grey level maximum value # ============================================================================= # PATTERN GENERATION # ============================================================================= n = (N-2) // 2 x = np.arange(N) - n y = np.arange(N) - n X,Y = np.meshgrid(x,y) autocorr = 1 - ( np.sqrt(X**2+Y**2) / n ) ** (2*H) #Auto-correlation function #definition FFT_square = np.fft.fft2(autocorr) FFT = FFT_square ** (1/2) np.random.seed(seed) psi = np.random.uniform(0,2*np.pi,(N,N)) #Uniform [0;2*pi] random phase FFT *= np.exp(1j*psi) h_aux1 = np.real(np.fft.ifft2(FFT)) h_aux1 = m*(h_aux1-np.min(h_aux1))/(np.max(h_aux1)-np.min(h_aux1)) h = h_aux1.astype('int') #Pattern h def F_mu_sigma(x,mu,sigma): return ((m+1)//2)*(1 + erf( (x - mu)/( np.sqrt(2)*sigma ) )) mu_gl = np.mean(h_aux1) sigma_gl = np.std(h_aux1) F_h = F_mu_sigma(h_aux1, mu_gl, sigma_over_sigma_gl * sigma_gl) F_h = m*(F_h-np.min(F_h))/(np.max(F_h)-np.min(F_h)) F_h = F_h.astype('int') #$F_{\mu,sigma_over_sigma_gl*\sigma_{gl}}(h)$ # ============================================================================= # PATTERN PLOT # ============================================================================= plt.figure() plt.subplot(121) plt.imshow(h,cmap='gray') plt.title('h') plt.subplot(122) plt.imshow(F_h,cmap='gray') plt.title('$F_{\mu,'+str(sigma_over_sigma_gl)+'\sigma_{gl}}(h)$')