2017-10-12 20 views
0

Sequoia 앵무새 센서에서 캡처 한 .tif 이미지로 작업하고 있습니다. 방사성 보정을 수행하고 결과 이미지를 동일한 형식 (.tif)으로 내보내고 싶습니다..tif 파일 가져 오기, 처리, 편집 및 내보내기 R

이미지를 래스터로 가져온 다음 일부 알고리즘으로 처리하고 마지막으로 .tif 파일로 내보내려고하지만 열 수 없습니다. 결과 파일은 7MB이지만 이미지를 볼 수 없습니다.

setwd("/where the images are/") 
rlist=list.files(getwd(), pattern="TIF$", full.names=F) 
options(digits=20) 

for(i in rlist){ 
    data <- raster(i) 

meta <- exifr(i, recursive = FALSE, quiet = TRUE, exiftoolargs = NULL) 
SM <- meta$SensorModel 
SM <- strsplit(SM, ",")[[1]] 
A <- as.numeric(SM[1]) 
B <- as.numeric(SM[2]) 
C <- as.numeric(gsub("[^0-9\\.]", "", SM[3])) 

Ep <- meta$ExposureTime ## Epsilon 
f <- meta$FNumber ## Focus Number 
ys <- meta$ISO ##ISO 

I <- f^2*(data-B)/(A*Ep*ys+C) 
I <- flip(I,"x") 
I <- flip(I,"y") 
+0

내가 사용하는 것이다'CALC()'최초'I' 계산에서 :

나는 더 나은 이해를위한 작은 변화를했다. 예제 이미지가 없으면 문제를 파악하는 데 도움을 줄 수 없습니다. –

답변

0

는 원래 스크립트가 잘 들여 : 여기

내 스크립트입니다? 예제 이미지로 모든 것이 올바르게 작동합니다.

library(raster) 
library(exifr) 

setwd("/where the images are/") 
rlist=list.files(getwd(), pattern="TIF$", full.names=F) 
options(digits=20) 

for(i in seq_along(rlist)){ # small change 

    data <- raster(rlist[i]) # small change 

    meta <- exifr(rlist[i], recursive = FALSE, quiet = TRUE, exiftoolargs = NULL) # small change 
    SM <- meta$SensorModel 
    SM <- strsplit(SM, ",")[[1]] 
    A <- as.numeric(SM[1]) 
    B <- as.numeric(SM[2]) 
    C <- as.numeric(gsub("[^0-9\\.]", "", SM[3])) 

    Ep <- meta$ExposureTime ## Epsilon 
    f <- meta$FNumber ## Focus Number 
    ys <- meta$ISO ##ISO 

    I <- calc(data,fun = function(x){f^2*(x-B)/(A*Ep*ys+C)}) # small change 
    I <- flip(I,"x") 
    I <- flip(I,"y") 
    print(plot(I)) 
} 

image