pixel_offset_stddev=0.05) # Make a noise injector producing 2% gaussian additive noise noise_injector = vlab.noise_injector("gaussian", sigma=.02) # Make an synthetic image generation pipeline image_generator = vlab.SyntheticImageGenerator(speckle_image=speckle_image, image_deformer=image_deformer, downsampler=downsampler, noise_injector=noise_injector, n=n_imgs) # Put it into an image stack image_stack = dic.ImageStack(image_generator) # Now, make a mesh. Make sure to use enough elements mesher = dic.Mesher(deg_n=3, deg_e=3, type="spline") #mesh = mesher.mesh(image_stack) # Use this if you want to mesh with a GUI mesh = mesher.mesh(image_stack, Xc1=50, Xc2=450, Yc1=50, Yc2=450, n_ely=8, n_elx=8, GUI=False) # Prepare the analysis input and initiate the analysis input = dic.DICInput(mesh, image_stack) input.tol = 1e-6 dic_job = dic.DICAnalysis(input)
logging.basicConfig(format='%(name)s:%(levelname)s:%(message)s', level=logging.INFO) # Path to folder containing images #path = r'./example_data/' # Use this formatting on Linux and Mac OS path = r'F:\GraduateProject\Python\PCA\speckle\\' # path = r'c:\path\to\example_data\\' # Use this formatting on Windows # Generate image instance containing all images found in the folder # images = dic.IO.image_stack_from_folder(path, file_type='.tif') images = dic.IO.image_stack_from_folder(path, file_type='.tif') images.set_filter(dic.filtering.lowpass_gaussian, sigma=1.) # Generate mesh # 这里Xc1,Xc2,Yc1,Yc2是ROI的大小,需要根据输入图象的大小修改 mesher = dic.Mesher(deg_e=3, deg_n=3) # mesh = mesher.mesh(images,Xc1=200,Xc2=1050,Yc1=200,Yc2=650,n_ely=8,n_elx=8, GUI=True) mesh = mesher.mesh(images, Xc1=20, Xc2=105, Yc1=20, Yc2=65, n_ely=8, n_elx=8, GUI=True) # Instantiate settings object and set some settings manually settings = dic.DICInput(mesh, images) # 图像数量 settings.max_nr_im = 2 settings.ref_update = [15] settings.maxit = 20 # If you want to access the residual fields after the analysis, this should be set to True settings.store_internals = False # Instantiate job object job = dic.DICAnalysis(settings)
def run_DIC(folder_path, n_images, filter, filter_sigma, maxim, maxit, padding, poly_order, converge): # Set the amount of info printed to terminal during analysis logging.basicConfig(format='%(name)s:%(levelname)s:%(message)s', level=logging.INFO) # Path to folder containing images path = folder_path # Generate image instance containing all images found in the folder images = dic.IO.image_stack_from_folder(path, file_type='.png') images.use_every_n_image(int(n_images)) if filter == "Lowpass Gaussian": images.set_filter(dic.filtering.lowpass_gaussian, sigma=int(filter_sigma)) elif filter == "Highpass Gaussian": images.set_filter(dic.filtering.highpass_gaussian, sigma=int(filter_sigma)) elif filter == "Homomorphic Median": images.set_filter(dic.filtering.homomorphic_median, sigma=int(filter_sigma)) else: pass # Generate mesh mesher = dic.Mesher(deg_e=3, deg_n=3, type="q4") #type="b_splines") mesh = mesher.mesh(images, Xc1=316, Xc2=523, Yc1=209, Yc2=1055, n_ely=18, n_elx=5, GUI=True) # Instantiate settings object and set some settings manually (first video) settings = dic.DICInput(mesh, images) if bool(maxim): settings.max_nr_im = int(maxim) settings.ref_update = [15] settings.maxit = int(maxit) settings.tol = 1.e-6 settings.interpolation_order = int(poly_order) # If you want to access the residual fields after the analysis, this should be set to True settings.store_internals = True # This setting defines the behaviour when convergence is not obtained if converge == "Ignore": settings.noconvergence = "ignore" elif converge == "Update": settings.noconvergence = "update" elif converge == "Break": settings.noconvergence = "break" else: pass # Instantiate job object job = dic.DICAnalysis(settings) # Running DIC analysis dic_results = job.run() return images, dic_results
import logging # Set the amount of info printed to terminal during analysis logging.basicConfig(format='%(name)s:%(levelname)s:%(message)s', level=logging.INFO) # Path to folder containing images path = r'./example_data/' # Use this formatting on Linux and Mac OS #path = r'c:\path\to\example_data\\' # Use this formatting on Windows # Generate image instance containing all images found in the folder images = dic.IO.image_stack_from_folder(path, file_type='.tif') #images.set_filter(dic.filtering.lowpass_gaussian, sigma=1.) # Generate mesh mesher = dic.Mesher(deg_e=3, deg_n=3, type="q4") # If you want to see use a GUI, set GUI=True below mesh = mesher.mesh(images, Xc1=316, Xc2=523, Yc1=209, Yc2=1055, n_ely=36, n_elx=9, GUI=False) # If you want to visualize nodes label mesh.visualize_node() # Instantiate settings object and set some settings manually
# Instantiate an image deformer image_deformer = vlab.image_deformer.imageDeformer_rigid_body(amp=(shift_amp, 0.)) # Shift the images. Note that the first one is not shifted shifted_images = image_deformer(img, n_imgs) # We now add noise to the images shifted_noisy_images = [noise_injector(image) for image in shifted_images] # And put them into a stack which is the formatting needed for the DIC analysis image_stack = dic.image_stack_from_list(shifted_noisy_images) # Generate mesh # We here use Q4 elements mesher = dic.Mesher(type="q4") # If you want to use a GUI, set GUI=True mesh = mesher.mesh(image_stack, Xc1=20, Xc2=480, Yc1=20, Yc2=480, n_ely=num_elms, n_elx=num_elms, GUI=False) # Instantiate settings object and set some settings manually settings = dic.DICInput(mesh, image_stack) # We allow the solver to use as many iterations as it needs settings.maxit = 100 # This tolerance is the larges increment in nodal position [pixels] settings.tol = 1e-6 # We use fourth order splines for grey-scale interpolation, minimizing interpolation bias settings.interpolation_order = 4 # Instantiate job object job = dic.DICAnalysis(settings) # Running DIC analysis