gtatters / Thermimage

R Package for working with radiometric thermal image files and data
GNU General Public License v3.0
164 stars 41 forks source link

Error in raw2temp #15

Closed jsgutierr closed 3 years ago

jsgutierr commented 3 years ago

After having installed the package (including Exiftool, Imagemagick & Perl) and read the image included with Thermimage ("IR_2412.jpg"), I get an error when trying to convert raw thermal data into temperature:

temperature<-raw2temp(img, ObjectEmissivity, OD, ReflT, AtmosT, IRWinT, IRWinTran, RH, PlanckR1, PlanckB, PlanckF, PlanckO, PlanckR2, ATA1, ATA2, ATB1, ATB2, ATX)

Error in raw2temp(raw, E, OD, RTemp, ATemp, IRWTemp, IRT, RH, PR1, PB, : object 'IRT' not found

sessionInfo() R version 3.6.2 (2019-12-12) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Catalina 10.15.5 Thermimage_4.0.1

I also get the same error when trying to reproduce the example with my laptop: sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Sierra 10.12.6 Thermimage_4.0.1 tgp_2.4-16 sp_1.4-2

Perhaps I am missing something very obvious. Many thanks

gtatters commented 3 years ago

have you tried running the entire example in readFLIRJPG? What is pasted above is not enough for me to tell that you succeeded in creating all the variables required for raw2temp to work. You will need to populate some of these inputs yourself, which is facilitated with the example:

`

library(Thermimage) imagefile<-paste0(system.file("extdata/IR_2412.jpg", package="Thermimage"))

cams<-flirsettings(imagefile, exiftool="installed", camvals="") cams

Emissivity<-cams$Info$Emissivity # Image Saved Emissivity - should be ~0.95 or 0.96 ObjectEmissivity<-0.96 # Object Emissivity - should be ~0.95 or 0.96 dateOriginal<-cams$Dates$DateTimeOriginal dateModif<- cams$Dates$FileModificationDateTime PlanckR1<- cams$Info$PlanckR1 # Planck R1 constant for camera
PlanckB<- cams$Info$PlanckB # Planck B constant for camera
PlanckF<- cams$Info$PlanckF # Planck F constant for camera PlanckO<- cams$Info$PlanckO # Planck O constant for camera PlanckR2<- cams$Info$PlanckR2 # Planck R2 constant for camera OD<- cams$Info$ObjectDistance # object distance in metres FD<- cams$Info$FocusDistance # focus distance in metres ReflT<- cams$Info$ReflectedApparentTemperature # Reflected apparent temperature AtmosT<- cams$Info$AtmosphericTemperature # Atmospheric temperature IRWinT<- cams$Info$IRWindowTemperature # IR Window Temperature IRWinTran<- cams$Info$IRWindowTransmission # IR Window transparency RH<- cams$Info$RelativeHumidity # Relative Humidity h<- cams$Info$RawThermalImageHeight # sensor height (i.e. image height) w<- cams$Info$RawThermalImageWidth # sensor width (i.e. image width)

img<-readflirJPG(imagefile)

imgr<-rotate270.matrix(img)

library(fields) image.plot(imgr, useRaster=TRUE, col=ironbowpal)

temperature<-raw2temp(imgr,ObjectEmissivity,OD,ReflT,AtmosT,IRWinT,IRWinTran,RH, PlanckR1,PlanckB,PlanckF,PlanckO,PlanckR2) colnames(temperature)<-NULL rownames(temperature)<-NULL

t<-temperature image.plot(t, asp=h/w, bty="n", useRaster=TRUE, xaxt="n", yaxt="n", col=ironbowpal)

library(ggplot2) library(reshape2) d<-melt(temperature)

p<-ggplot(d, aes(Var1, Var2))+ geom_raster(aes(fill=value))+coord_fixed()+ scale_fill_gradientn(colours=ironbowpal)+ theme_void()+ theme(legend.key.height=unit(2, "cm"), legend.key.width=unit(0.5, "cm")) p

jsgutierr commented 3 years ago

My bad... I had skipped the chuck where all relevant variables are specified - I somehow thought they were specified by default in 'raw2temp'. It now works perfectly, many thanks!

On Mon, Sep 21, 2020 at 5:18 PM Glenn Tattersall notifications@github.com wrote:

have you tried running the entire example in readFLIRJPG? What is pasted above is not enough for me to tell that you succeeded in creating all the variables required for raw2temp to work. You will need to populate some of these inputs yourself, which is facilitated with the example:

`

library(Thermimage) imagefile<-paste0(system.file("extdata/IR_2412.jpg", package="Thermimage"))

cams<-flirsettings(imagefile, exiftool="installed", camvals="") cams

Emissivity<-cams$Info$Emissivity # Image Saved Emissivity - should be ~0.95 or 0.96 ObjectEmissivity<-0.96 # Object Emissivity - should be ~0.95 or 0.96 dateOriginal<-cams$Dates$DateTimeOriginal dateModif<- cams$Dates$FileModificationDateTime PlanckR1<- cams$Info$PlanckR1 # Planck R1 constant for camera PlanckB<- cams$Info$PlanckB # Planck B constant for camera PlanckF<- cams$Info$PlanckF # Planck F constant for camera PlanckO<- cams$Info$PlanckO # Planck O constant for camera PlanckR2<- cams$Info$PlanckR2 # Planck R2 constant for camera OD<- cams$Info$ObjectDistance # object distance in metres FD<- cams$Info$FocusDistance # focus distance in metres ReflT<- cams$Info$ReflectedApparentTemperature # Reflected apparent temperature AtmosT<- cams$Info$AtmosphericTemperature # Atmospheric temperature IRWinT<- cams$Info$IRWindowTemperature # IR Window Temperature IRWinTran<- cams$Info$IRWindowTransmission # IR Window transparency RH<- cams$Info$RelativeHumidity # Relative Humidity h<- cams$Info$RawThermalImageHeight # sensor height (i.e. image height) w<- cams$Info$RawThermalImageWidth # sensor width (i.e. image width)

img<-readflirJPG(imagefile)

imgr<-rotate270.matrix(img)

library(fields) image.plot(imgr, useRaster=TRUE, col=ironbowpal)

temperature<-raw2temp(imgr,ObjectEmissivity,OD,ReflT,AtmosT,IRWinT,IRWinTran,RH, PlanckR1,PlanckB,PlanckF,PlanckO,PlanckR2) colnames(temperature)<-NULL rownames(temperature)<-NULL

t<-temperature image.plot(t, asp=h/w, bty="n", useRaster=TRUE, xaxt="n", yaxt="n", col=ironbowpal)

library(ggplot2) library(reshape2) d<-melt(temperature)

p<-ggplot(d, aes(Var1, Var2))+ geom_raster(aes(fill=value))+coord_fixed()+ scale_fill_gradientn(colours=ironbowpal)+ theme_void()+ theme(legend.key.height=unit(2, "cm"), legend.key.width=unit(0.5, "cm")) p

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gtatters/Thermimage/issues/15#issuecomment-696183316, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARCVPNUVBF4DXDXEZK6NJBDSG5VGHANCNFSM4RUUX5XA .

gtatters commented 3 years ago

no worries. It's good to ask.
My function coding isn't perfect. Usually they are all working by default since I do populate with my camera's default values (danger for others since they will be completely wrong by default!).

Maybe there was a syntax error with IRT but I noticed my example has IRWinTran spelled out. That could be me being inconsistent between examples. Thanks for bringing it up. I might need to fix the help files!