def make_bltm_figure(): figure = pyxel.Image(pyxel.width, pyxel.height) figure.cls(BG_COLOR) image1 = pyxel.Image(32, 24) image1.blt(0, 0, 0, 0, 64, 32, 24) image1 = scale_image(image1, 3) image2 = pyxel.Image(32, 24) image2.blt(0, 0, 0, 0, 96, 32, 24) image2 = scale_image(image2, 3) x = 10 y = 12 col = 7 bcol = 0 text_with_border(figure, x + 1, y - 7, "Tilemap", col, bcol) figure.blt(x, y, image1, 0, 0, image1.width, image1.height) col = 8 bcol = 7 text_with_border(figure, x + 3, y + 10, "(0,0) (0,0) (0,1) (0,2)", col, bcol) text_with_border(figure, x + 3, y + 34, "(3,2) (0,0) (0,0) (1,2)", col, bcol) text_with_border(figure, x + 3, y + 58, "(3,2) (2,2) (0,0) (0,2)", col, bcol) x = 116 col = 7 bcol = 0 text_with_border(figure, x + 1, y - 7, "Image Bank (refimg)", col, bcol) figure.blt(x, y, image2, 0, 0, image2.width, image2.height) return figure
def make_blt_figure(): figure = pyxel.Image(pyxel.width, pyxel.height) figure.cls(BG_COLOR) image1 = pyxel.Image(32, 24) image1.blt(0, 0, 0, 0, 0, 32, 24) image1 = scale_image(image1, 3) image2 = pyxel.Image(32, 24) image2.blt(0, 0, 0, 0, 32, 32, 24) image2 = scale_image(image2, 3) col = 7 bcol = 0 def draw_w_and_h(x, y): pset_with_border(figure, x + 47, y + 23, col, bcol) line_with_border(figure, x + 47, y + 47, x + 70, y + 47, col, bcol) text_with_border(figure, x + 58, y + 44, "w", col, bcol) line_with_border(figure, x + 71, y + 23, x + 71, y + 46, col, bcol) text_with_border(figure, x + 70, y + 33, "h", col, bcol) x = 10 y = 12 figure.blt(x, y, image1, 0, 0, image1.width, image1.height) text_with_border(figure, x + 1, y - 7, "Screen", col, bcol) text_with_border(figure, x + 38, y + 16, "(x,y)", col, bcol) draw_w_and_h(x, y) x = 116 figure.blt(x, y, image2, 0, 0, image2.width, image2.height) text_with_border(figure, x + 1, y - 7, "Image Bank", col, bcol) text_with_border(figure, x + 38, y + 16, "(u,v)", col, bcol) draw_w_and_h(x, y) return figure
def scale_image(image, scale): scaled_width = image.width * scale scaled_height = image.height * scale scaled_image = pyxel.Image(scaled_width, scaled_height) for y in range(scaled_height): for x in range(scaled_width): color = image.pget(x // scale, y // scale) scaled_image.pset(x, y, color) return scaled_image
def __init__(self, parent): super().__init__(parent, 157, 16, 66, 65) self._tilemap_image = pyxel.Image(64, 63) self.copy_var("tilemap_no_var", parent) self.copy_var("help_message_var", parent) # Initialize focus_x_var self.new_var("focus_x_var", 0) self.add_var_event_listener("focus_x_var", "set", self.__on_focus_x_set) # Initialize focus_y_var self.new_var("focus_y_var", 0) self.add_var_event_listener("focus_y_var", "set", self.__on_focus_y_set) # Set event listeners self.add_event_listener("mouse_down", self.__on_mouse_down) self.add_event_listener("mouse_drag", self.__on_mouse_drag) self.add_event_listener("mouse_hover", self.__on_mouse_hover) self.add_event_listener("update", self.__on_update) self.add_event_listener("draw", self.__on_draw)
JC Passieux, INSA Toulouse, 2021 Example 8 : ADVANCED Implement the inverse compositional Gauss Newton [REF] JC. Passieux and R. Bouclier. Classic and Inverse Compositional Gauss-Newton in Global DIC. International Journal for Numerical Methods in Engineering, 119(6), p.453-468, 2019. """ import numpy as np import scipy.sparse.linalg as splalg import pyxel as px f = px.Image('zoom-0053_1.tif').Load() g = px.Image('zoom-0070_1.tif').Load() m = px.ReadMeshINP('abaqus_q4_m.inp') p = np.array( [1.05449047e+04, 5.12335842e-02, -9.63541211e-02, -4.17489457e-03]) cam = px.Camera(p) m.Connectivity() m.DICIntegration(cam, G=True) U0 = px.MultiscaleInit(f, g, m, cam, scales=[3, 2, 1], l0=0.002) #%% ICGN
""" Finite Element Digital Image Correlation method JC Passieux, INSA Toulouse, 2017 """ import numpy as np import scipy.sparse.linalg as splalg import scipy as sp import pyxel as px #%% ============================================================================ # Datafiles, images and mesh ================================================= # ============================================================================== imnums=np.array([53,54,57,58,61,62,65,66,69,70,75]) imagefile='./data/dic_composite/zoom-0%03d_1.tif' imref = imagefile % imnums[0] f=px.Image(imref).Load() f.Show() # Triangular Mesh in milimeter m=px.ReadMeshGMSH('./data/dic_composite/gmsh_t3_mm.msh') #cam=px.MeshCalibration(f,m,[1,2]) cam=px.Camera(np.array([10.49882137, 51.07774613, -6.53402857, 1.56607077])) l0=1 # regularization length # Quadrilateral Mesh in meter m=px.ReadMeshINP('./data/dic_composite/abaqus_q4_m.inp') #cam=px.MeshCalibration(f,m,[1,2]) cam=px.Camera(np.array([ 1.05168768e+04, 5.13737634e-02, -9.65935782e-02, -2.65443047e-03])) l0=0.005 # regularization length
def __init__(self, parent): super().__init__(parent, 11, 16, 130, 130) if hasattr(parent, "tilemap_no_var"): self._is_tilemap_mode = True self.copy_var("tilemap_no_var", parent) self.copy_var("tile_x_var", parent) self.copy_var("tile_y_var", parent) self.copy_var("tile_w_var", parent) self.copy_var("tile_h_var", parent) else: self._is_tilemap_mode = False self._history_data = None self._press_x = 0 self._press_y = 0 self._last_x = 0 self._last_y = 0 self._drag_offset_x = 0 self._drag_offset_y = 0 self._select_x1 = 0 self._select_y1 = 0 self._select_x2 = 0 self._select_y2 = 0 self._copy_buffer = None self._is_dragged = False self._is_assist_mode = False self._edit_canvas = (pyxel.Tilemap(16, 16, 0) if self._is_tilemap_mode else pyxel.Image(16, 16)) self.add_history = parent.add_history self.copy_var("color_var", parent) self.copy_var("tool_var", parent) self.copy_var("image_no_var", parent) self.copy_var("canvas_var", parent) self.copy_var("focus_x_var", parent) self.copy_var("focus_y_var", parent) self.copy_var("help_message_var", parent) # Initialize horizontal scroll bar self._h_scroll_bar = ScrollBar( self, 0, 129, width=130, scroll_amount=32, slider_amount=2, value=0, ) self._h_scroll_bar.add_event_listener("change", self.__on_h_scroll_bar_change) self.add_var_event_listener("focus_x_var", "change", self.__on_focus_x_change) # Initialize vertical scroll bar self._v_scroll_bar = ScrollBar( self, 129, 0, height=130, scroll_amount=32, slider_amount=2, value=0, ) self._v_scroll_bar.add_event_listener("change", self.__on_v_scroll_bar_change) self.add_var_event_listener("focus_y_var", "change", self.__on_focus_y_change) # Initialize event listeners self.add_event_listener("mouse_down", self.__on_mouse_down) self.add_event_listener("mouse_up", self.__on_mouse_up) self.add_event_listener("mouse_click", self.__on_mouse_click) self.add_event_listener("mouse_drag", self.__on_mouse_drag) self.add_event_listener("mouse_hover", self.__on_mouse_hover) self.add_event_listener("update", self.__on_update) self.add_event_listener("draw", self.__on_draw)
# -*- coding: utf-8 -*- """ Finite Element Digital Image Correlation method JC Passieux, INSA Toulouse, 2021 Example 2 : BASIC Analyse an image series. """ import numpy as np import pyxel as px imnums = np.array([53, 54, 57, 58, 61, 62, 65, 66, 69, 70, 75]) imagefile = 'zoom-0%03d_1.tif' imref = imagefile % imnums[0] f = px.Image(imref).Load() m = px.ReadMeshINP('abaqus_q4_m.inp') p = np.array( [1.05449047e+04, 5.12335842e-02, -9.63541211e-02, -4.17489457e-03]) cam = px.Camera(p) m.Connectivity() m.DICIntegration(cam) UU = px.CorrelateTimeIncr(m, f, imagefile, imnums, cam, [3, 2, 1, 0]) m.AnimatedPlot(UU, 30) m.VTKSolSeries('example_2', UU)