IR photos with the Boscam HD19, part 1
On my multicopter, I have a Boscam HD19 camera. This camera was explicitely developed for use on UAVs and has some interesting functions, like live video out, full HD recording and taking photos. The recording functions can also be controlled via the UAV’s remote control, which makes it especially useful. The stock lens is very wide-angeled and - in my opinion - not of excessively good quality. Fortunately, the HD19 uses a standard 12x0,5mm thread for lenses and good but cheap lenses in various angles are available from the internet.
As of all digital cameras, the sensor of the HD 19 is also sensitive to infrared light. However, the HD19’s stock lens has an IR-cut filter because IR light is very prominent in the light spectrum and would otherwise cause the picture’s colors to be distorted.
So, to get infrared light, we either have to remove the IR-cut filter from the stock lens or get a lens without filter. As I didn’t like the wide angle of the stock lens and I had some problems with unsharp edges, I decided to buy a 6mm lens on eBay for about 6€ incl. shipping. It is noticeable that the HD19 has a 1/2.5” sensor. Most cheap CCD and CMOS cameras with M12 lenses have 1/3” or 1/4” lenses which leads to a small tunnel effect on photos with the HD19. Thus, only lenses for 1/2.5” sensors should be used. Those lenses are also often called “HD” or “3 Megapixel / 3MP lenses”.
To make things easier, I have written a small Scheme script for GIMP which does the correction automatically. /see below)
Part 2 will cover postprocessing of images which were taken with an IR-passthrough filter.
;
; IR photo postprocessing
;
; Correct colors in photos without IR-cut lens and swap red and blue
; channels in photos with IR passthrough filter.
;
; Stefan Gofferje (stefan@gofferje.net)
; (C) 2013, Valkeakoski, Finland
;
; This script was tested with Gimp 2.8
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, see <http://www.gnu.org/licenses>.
;
; Define the function
;
(define (script-fu-SGO-IRpostproc InImage InLayer InSwitchRB)
;
; Save history
;
(gimp-image-undo-group-start InImage)
;
(let* (
(SwitchLayer (car (gimp-layer-copy InLayer TRUE)))
)
(gimp-image-insert-layer InImage SwitchLayer 0 -1)
(cond
(
(= InSwitchRB FALSE)
;auto white-balance
(gimp-levels-stretch SwitchLayer)
;correct more
(gimp-curves-spline SwitchLayer HISTOGRAM-RED 6 #(0 0 105 45 255 255))
(gimp-curves-spline SwitchLayer HISTOGRAM-GREEN 6 #(0 0 100 105 255 255))
(gimp-curves-spline SwitchLayer HISTOGRAM-BLUE 6 #(0 0 90 95 255 255))
;remove cyan component
(gimp-hue-saturation SwitchLayer 4 0 0 -100)
)
)
(cond
(
(= InSwitchRB TRUE)
(let* (
(RGBImage (car (plug-in-decompose TRUE InImage SwitchLayer "RGB" TRUE)))
(RGBLayer (cadr (gimp-image-get-layers RGBImage)))
(CompImage (car (plug-in-drawable-compose TRUE RGBImage (aref RGBLayer 2) (aref RGBLayer 1) (aref RGBLayer 0) -1 "RGB")))
(CompLayer (cadr (gimp-image-get-layers CompImage)))
)
(gimp-selection-all CompImage)
(gimp-edit-copy (aref CompLayer 0))
(gimp-floating-sel-anchor (car (gimp-edit-paste SwitchLayer FALSE)))
(gimp-image-delete CompImage)
(gimp-image-delete RGBImage)
)
)
)
)
;
; Finish work
;
(gimp-image-undo-group-end InImage)
(gimp-displays-flush)
;
)
;
(script-fu-register
"script-fu-SGO-IRpostproc"
_"Infrared _Postprocessing"
"Do some postprocessing on IR images"
"Stefan Gofferje (stefan@gofferje.net)"
"Stefan Gofferje, Valkeakoski, Finland"
"10.08.2013"
"RGB*"
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Layer" 0
SF-TOGGLE "Image was taken with IR passthrough filter" FALSE
)
;
(script-fu-menu-register "script-fu-SGO-IRpostproc"
"<Image>/Filters/SGO")
;