This file contains 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
using VideoIO | |
using Images | |
download("https://live.staticflickr.com/4293/35896494470_6e106950d9_o_d.jpg","input.jpg") | |
img = load("input.jpg") | |
(h,w) = size(img) | |
function getframe(img, dx, dy, N, scaleup) | |
smimg = img[dy:(dy+(N-1)),dx:(dx+(N-1))] | |
bigpix = repeat(smimg, inner=(scaleup,scaleup)) |
This file contains 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
using VideoIO | |
using Images | |
download("https://live.staticflickr.com/4293/35896494470_6e106950d9_o_d.jpg","input.jpg") | |
img = load("input.jpg") | |
(h,w) = size(img) | |
function getframe(img, dx, dy, N, scaleup) | |
smimg = img[dy:(dy+(N-1)),dx:(dx+(N-1))] | |
bigpix = repeat(smimg, inner=(scaleup,scaleup)) |
This file contains 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
using Images | |
smallpix = rand(UInt8, 8, 8) | |
bigpix = repeat(smallpix, inner=(200,200)) | |
save("greychess.png",bigpix) |
This file contains 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 fpdf | |
def makePage(w=297,h=210): | |
'''Page width and height in mm. Default is A4 landscape''' | |
pdf = fpdf.FPDF(unit='mm', format=(w, h)) | |
pdf.add_page() | |
return(pdf) | |
def drawLines(pdf, titlegap = 30, stafflinegap = 4, linegap = 10): | |
'''All dimensions in mm. 5 lines for music notation. |
This file contains 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 numpy as np | |
from PIL import Image | |
# Open a multichannel image | |
# In this example, an RGB image | |
fname = r"C:\Users\Conor\Downloads\PXL_20240304_174814563.MP.jpg" | |
im = Image.open(fname) | |
arr = np.array(im,dtype=np.uint8) |
This file contains 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
seed(99) | |
N = 100 | |
x = runif(N) | |
noise = rnorm(N,mean=0,sd=0.1) | |
y_corr = 1*x + noise | |
y_nocorr = noise | |
rsq_corr = cor(x,y_corr) | |
rsq_nocorr = cor(x,y_nocorr) | |
plot(x,y_corr,xlim=c(0,1),ylim=c(-0.3,1.0),pch=16,xlab="x",ylab="y",cex.lab=1.55) |
This file contains 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 fpdf import FPDF | |
def makeGrid(w=210.0, h=297.0, nrow=5, ncol=4, outf="grid.pdf", grey = 220, dl=3, sl=2, lwd=0.2): | |
'''Writes a single page pdf of width w mm and height h mm (defaults are A4) with a nrow x ncol grid | |
traced out on it, to file outf. Grid is a thin line (thickness is lwd) coloured grey (default is very | |
light grey) with dashing specified by dash length dl and space length sl.''' | |
pdf = FPDF(orientation="P", unit="mm", format=(w,h)) | |
deltax = float(w)/ncol | |
deltay = float(h)/nrow |
This file contains 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
# Plot wide data | |
test = data.frame(id=1:4,"A"=1:4,"B"=5:8,"C"=11:14) | |
# Plot original order | |
stripchart(test[,2:4]) | |
# Plot updated order | |
stripchart(test[,c("C","A","B")]) | |
# Plot long data | |
test2 = reshape(test,direction="long",varying=c("A","B","C"),v.names="Value",idvar=c("id"),timevar=c("Label"),times=c("A","B","C")) | |
# Plot original order |
This file contains 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
# A possible problem with freezing artefacts and correlations | |
# Need MASS library to sample from multivariate normal distribution (correlated datasets) | |
library(MASS) | |
R_good = matrix(c(0.55, 0.5, | |
0.5, 0.55), | |
nrow = 2, ncol = 2, byrow = TRUE) | |
R_bad = matrix(c(1, 0.5, | |
0.5, 1), |
This file contains 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 cv2 | |
import time | |
from pathlib import Path | |
import os | |
cam = cv2.VideoCapture(1) | |
cam.set(3, 1920) | |
cam.set(4, 1080) | |
cv2.namedWindow("test") |
NewerOlder