Skip to content

Instantly share code, notes, and snippets.

View mkitti's full-sized avatar

Mark Kittisopikul mkitti

View GitHub Profile
"Allows for the splitting output among several AbstractDisplays"
module Tee
import Base.Multimedia.display
import Base.TextDisplay
import Base: flush, close
export TeeDisplay, display, teeDisplay, FlushingTextDisplay, flush, close
"""
TeeDisplay(displays::Vector{AbstractDisplay})
TeeDisplay(args::AbstractDisplay...)
@mkitti
mkitti / zgelss.jl
Last active January 24, 2020 12:11
# Hacked toether from https://github.com/JuliaLang/julia/blob/2d5741174ce3e6a394010d2e470e4269ca54607f/stdlib/LinearAlgebra/src/lapack.jl#L1371
# http://www.netlib.org/lapack/explore-html/d6/d10/group__complex16_g_esolve_ga61e68db68886c3f80753fac87ca35a6e.html#ga61e68db68886c3f80753fac87ca35a6e
using LinearAlgebra
const liblapack = Base.liblapack_name
import LinearAlgebra.LAPACK.chklapackerror, LinearAlgebra.LAPACK.subsetrows
import ..LinearAlgebra.BLAS.@blasfunc
@mkitti
mkitti / SamplePairs.jl
Created January 20, 2020 06:25
Sample pairs of values from vectors x and y without replacement
import StatsBase
"""
xs,ys = samplePairs(x,y,nSamples=length(x)*length(y))
Samples a pair of values, one from x and one from y, without repetition
"""
function samplePairs(x::AbstractVector{T}, y::AbstractVector{T}; nSamples=length(x)*length(y)) where {T}
xout = Vector{T}(undef,nSamples)
yout = Vector{T}(undef,nSamples)
p = length(x)*length(y)
s = zeros(Int,nSamples)
// Rolling Ball Test via Binary 3D Landscape
// Mark Kittisopikul
// December 2019
// References
// 1. SR Sternberg. Biomedical Image Processing. IEEE Computer 1983.
// https://doi.ieeecomputersociety.org/10.1109/MC.1983.1654163
// 2. SR Sternberg. Grayscale Morphology. CVGIP 1986
// https://doi.org/10.1016/0734-189X(86)90004-6
// 3. R Adams. “Radial Decomposition of Discs and Spheres”.
@mkitti
mkitti / rollingBallBackgroundViaBinary3D.m
Created December 1, 2019 09:53
Rolling ball background estimation using a binary 3D volume
function [bg,image,binary3D] = rollingBallBackgroundViaBinary3D(image,ballRadius,smooth)
%rollingBallBackgroundViaBinary3D Calculate rolling ball background
%
% INPUT
% image - 2D image of positive integers
% ballRadius - (optional) radius of rolling ball, default: 5
% smooth - (optional) radius for Gaussian smoothing
%
% OUTPUT
% bg - rolling ball estimated background
# coding: utf-8
# https://twitter.com/loicaroyer/status/1146173537658404864
#
# #Python Twitter Challenge
# Given a list of integers u=[a_0, ..., a_m]
# find the set of indices {i_0, ..., i_n} for that list such that the product
# u[i_0]* ... *u[i_n] is the closest to a given integer N.
# The shortest and most #elegant solution wins.
# (standard libs allowed)
#