This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Image segmentation using a trivial implementation of Lloyd's k-means algorithm in numpy | |
""" | |
import numpy as np | |
import cv2 as cv | |
# INPUTS | |
k = 5 # k-means number of clusters | |
eps = 1e-8 # loop ending condition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
num_points = 10 | |
x, y = np.random.uniform(-1, 1, size=(2, num_points)) | |
# Calculate the angle of each point with respect to the origin | |
theta = np.arctan2(y, x) * 180 / np.pi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
# Number of random x,y points to generate | |
num_samples = 1000000 | |
# Set the seed for reproducibility | |
np.random.seed(42) | |
# Generate random x,y points in the unit square |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2023 Michele Castriotta | |
import math | |
import sys | |
from functools import partial | |
import numpy as np | |
from mpi4py import MPI | |
from petsc4py import PETSc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2022 Fabio Grasso, Michele Castriotta | |
# | |
# Fabio Grasso: | |
# f.grasso@isac.cnr.it | |
# | |
# Michele Castriotta | |
# mich.castriotta@gmail.com | |
Bootstrap: library |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://pythonprogramming.altervista.org/png-to-gif/ | |
import subprocess | |
import os | |
i = "*.png" | |
o = "output.gif" | |
subprocess.call("convert -delay 4 -loop 0 " + i + " " + o, shell=True) | |
os.system("start output.gif") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# trace generated using paraview version 5.10.1 | |
#import paraview | |
#paraview.compatibility.major = 5 | |
#paraview.compatibility.minor = 10 | |
| |
#### import the simple module from the paraview | |
from paraview.simple import * | |
#### disable automatic camera reset on 'Show' | |
paraview.simple._DisableFirstRenderCameraReset() | |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
For the slider, I've used the solution at this link: | |
https://stackoverflow.com/questions/6697259/interactive-matplotlib-plot-with-two-sliders | |
""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from matplotlib.widgets import Slider, Button, RadioButtons | |
def fano_func(w, w0, gamma, F): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
For the slider, I've used the solution at this link: | |
https://stackoverflow.com/questions/6697259/interactive-matplotlib-plot-with-two-sliders | |
""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from matplotlib.widgets import Slider, Button, RadioButtons | |
w0 = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os, sys, gi | |
gi.require_version('Wnck', '3.0') | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, Wnck | |
# Edit this as you like with your mpv options | |
mpv_title = 'MPV Wallpaper' | |
mpv_options = '--no-audio --loop --no-input-default-bindings --no-osc' |