fork download
  1. library("jpeg")
  2. #針對特定座標以外的距離變黑
  3. dat <-read.csv("D:\\...\\MRT.tsv",header=FALSE,stringsAsFactors=TRUE,sep="\t")
  4. orgpic = readJPEG("D:\\...\\old folder\\test1 00001.jpg")
  5.  
  6. gazepoint<-function(orgpic,intensity)
  7. {
  8. newpic=orgpic
  9. dx=dim(orgpic)[1]
  10. dy=dim(orgpic)[2]
  11.  
  12. GPX=dat[2,35] #test1 00001.jpg需要第35行第2列之X座標
  13. GPY=dat[2,36] #test1 00001.jpg需要第36行第2列之Y座標
  14. #但test1 00002.jpg則需要第35與36行,第3列之X與Y座標
  15.  
  16. intensity=max(c(dx,dy))
  17. D2=intensity^2/64
  18.  
  19. for(i in 1:dx)
  20. {
  21. for(j in 1:dy)
  22. {
  23. d=(i-GPX)^2+(j-GPY)^2
  24. if(d>D2) newpic[i,j,]=newpic[i,j,]*exp(-(d-D2)/D2*intensity)
  25. }
  26. }
  27. return(newpic)
  28. }
  29. writeJPEG(gazepoint(orgpic), target ="D:\\...\\new folder\\test 00001.jpg", quality = 0.95)
Success #stdin #stdout #stderr 0.46s 79168KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error in library("jpeg") : there is no package called ‘jpeg’
Execution halted