Skip to content

Commit

Permalink
Add single photon imaging demo
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaakshat committed Nov 3, 2021
1 parent 62d4da7 commit 43ea696
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ch08.r
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ lines(theta, L_df$"12", lwd=6)
title(expression(paste("L(", theta, " | S = 12)")))
grid()

## ML estimation for single-photon imaging

# R code
library(imager)
lambda = as.data.frame(load.image("cameraman.tif"))
lambda = xtabs(value ~ x+y, data=lambda)
T = 100
x = c()
for (i in 1:T) x = append(x, rpois(length(lambda), lambda))
x = array(x, c(256, 256, 100))
y = (x>=1)
mu = apply(y, c(1,2), mean)
lambdahat = -log(1-mu)
fig1 = x[,,1]

# Flip matrix since image reads the matrix bottom up
flip_matrix = function(m) m[,nrow(m):1]

image(flip_matrix(fig1), col=gray.colors(255))

image(flip_matrix(lambdahat), col=gray.colors(255))

#############

0 comments on commit 43ea696

Please sign in to comment.