Skip to content

Instantly share code, notes, and snippets.

@jcupitt
jcupitt / colourdeconv.py
Created September 9, 2023 12:43
colour deconvolution with pyvips
#!/usr/bin/python3
import sys
import pyvips
from numpy import linalg
stain = [
[0.468, 0.023, 0.767],
[0.721, 0.141, 0.576],
[0.511, 0.990, 0.284]
@jcupitt
jcupitt / fetch-vs-crop.py
Created March 30, 2023 10:38
time fetch and crop for image read
#!/usr/bin/python3
import random
import time
import sys
import pyvips
if len(sys.argv) != 4:
print("usage: ./fetch-vs-crop.py IMAGE SIZE N-TILES")
@jcupitt
jcupitt / createtiff.c
Created December 10, 2022 12:40
make a multipage tiff file
/* compile with
*
* gcc -Wall createtiff.c `pkg-config libtiff --cflags --libs`
*/
#include <tiffio.h>
int
main (int argc, const char **argv)
{
/*
* add-profile.c ... paste an ICC profile into a JPG file, without
* decompress/recompress.
*
* Adapted from wrjpgcom.c
*
* compile with:
*
* gcc -g -Wall add-profile.c `pkg-config glib-2.0 --cflags --libs`
*/
You'd think __callStatic() would fire, but I see:
$ ./static.php
calling try_static_call in object context
calling try_static_call in object context
calling try_static_call in object context
calling try_static_call in object context
calling try_method_call in object context
$ php --version
@jcupitt
jcupitt / try1.cs
Created December 20, 2021 17:00
convert netvips to bitmap and back
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
using var image = NetVips.Image.NewFromFile(args[0]);
// make a System.Drawing bitmap from it
using var bitmap = NetVips.Extensions.BitmapConverter.ToBitmap(image);
@jcupitt
jcupitt / userChrome.css
Created December 6, 2021 17:55
user chrome for tree-style tabs
#main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar
> .toolbar-items {
opacity: 0;
pointer-events: none;
}
#main-window:not([tabsintitlebar="true"]) #TabsToolbar {
visibility: collapse !important;
}
#sidebar-header {
display: none;
@jcupitt
jcupitt / bounce.js
Created February 3, 2021 21:25
bouncy balls
let numBalls = 13;
let spring = 1.01;
let balls = [];
function setup() {
createCanvas(720, 400);
for (let i = 0; i < numBalls; i++) {
balls[i] = new Ball(
random(width),
random(height),
@jcupitt
jcupitt / pil-vips.py
Created January 19, 2021 10:04
pil - pyvips image resize benchmark
#!/usr/bin/python3
import time
import sys
from io import BytesIO
import pyvips
from PIL import Image # Pillow-SIMD
@jcupitt
jcupitt / error.log
Created November 30, 2020 15:50
error log
+ mirtk convert-pointset surfaces/CC00058XX09-11300/vtk/CC00058XX09-11300.L.whit
e.native.surf.vtk surfaces/CC00058XX09-11300/workbench//temp-CC00058XX09-11300.L
.white.native.surf.gii
Warning: In /usr/src/structural-pipeline/build/VTK/IO/Legacy/vtkDataReader.cxx,
line 462
vtkGenericDataObjectReader (0xf0d9e0): Reading file version: 5.1 with older read
er version 4.0
Warning: In /usr/src/structural-pipeline/build/VTK/IO/Legacy/vtkDataReader.cxx,
line 462