Skip to content

Instantly share code, notes, and snippets.

View mkitti's full-sized avatar

Mark Kittisopikul mkitti

View GitHub Profile
# 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)
#
@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
// 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 / 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)
@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
"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 / napari.jl
Last active December 28, 2020 19:31
Invoking Napari from Julia Language 1.3.1
"""
napari.jl
Test using PyCall.jl to invoke Napari ( http://github.com/napari ) from
the Julia language ( https://julialang.org/ ) 1.3.1
Mark Kittisopikul
January 29th, 2020
"""
#@output Integer nFrames
//Sum_contour_lengths_by_frame_
//Mark Kittisopikul
//February 14th, 2020
//Install into Fiji.app/plugins/Scripts/Plugins/Curve Tracing/
//Companion to https://github.com/jalmar/CurveTracing
//Add up
importClass(Packages.ij.IJ);
importClass(Packages.ij.plugin.frame.RoiManager)
@mkitti
mkitti / MWE_JavaCall_async_incorrect.jl
Created February 17, 2020 00:15
JavaCall does not work well with @async
using JavaCall;
println("I threw a wish in the well ...")
JavaCall.init()
println("Hey, I just met you and this is crazy")
jls = @jimport java.lang.System
version = jcall(jls,"getProperty",JString,(JString,),"java.version")
println("Java Version: ",version)
jlm = @jimport java.lang.Math
@async begin
println("But here's my number, so call me maybe")
@mkitti
mkitti / Manifest.toml
Last active March 26, 2020 08:42
SIR Notebook
# This file is machine-generated - editing it directly is not advised
[[AbstractTrees]]
deps = ["Markdown"]
git-tree-sha1 = "86d092c2599f1f7bb01668bf8eb3412f98d61e47"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.3.2"
[[Adapt]]
deps = ["LinearAlgebra"]