# Create figure # Seven z=matrix(-1,nrow=50,ncol=20) z[3:16,19]=1 z[3:16,18]=1 for(j in 2:17){ il=round((.6*j+4),0) ir=round((.6*j+6),0) z[il:ir,j]=1 } #z[16,17]=1 # Four z[18:30,9:10]=1 z[28:29,2:19]=1 for(j in 11:19){ il=round((.6*j+11),0) ir=round((.6*j+13),0) z[il:ir,j]=1 } # Zero for(j in 2:19){ il=round(32+.08*(j-10)^2,0) ir=round(34+.08*(j-10)^2,0) iul=round(45-.08*(j-10)^2,0) iur=round(47-.08*(j-10)^2,0) z[il:ir,j]=1 z[iul:iur,j]=1 } #Noise function znoise=function(z,p){ h=dim(z)[[1]] v=dim(z)[[2]] for(i in 1:h){ for(j in 1:v){ u=2*rbinom(1,1,(1-p))-1 z[i,j]=u*z[i,j] } } return(z) }