Log in

View Full Version : Creating Thermal Vision


actionman133
17th January 2005, 03:35
Hi all!

I was just doing some messing around and came up with this neat little - although entirely useless - novelty function.

It creates images that appear to be shot in infrared from typical film/video material. You can watch it in black and white (like you would see in the helicopter shots of Best Police Chases), or in colour thermal, like how the Predator sees in the movie of the same name.

I am aware that Mode is error ridden when it comes to the final Return line, but I know the numbers I want.

Potency is used to enhance the effect. When Base is levelled between 128 and 255, skin is particularly dim. Use potency to enhance the effect to bring the skin to almost-white. That way, in colour mode, it will come out as red.

Function Thermal (clip Last, int Mode, int Potency) {

Base = VtoY.Levels (128, 1, 255 - Potency, 0, 255)

Blue = Base.Levels (0, 1, 63, 192, 128)
Green = Base.Levels (64, 1, 95, 63, 0)
Yellow = Base.Levels (96, 1, 159, 127, 64)
Red = Base.Levels (160, 1, 255, 191, 255)


RedMask = Red.Levels (191, 1, 192, 0, 255)
BlueMask = Blue.Levels (128, 1, 129, 0, 255)

RedGreen = Overlay (Green, Red, mask = RedMask)
BlueYellow = Overlay (Yellow, Blue, mask = BlueMask)

YtoUV (BlueYellow, RedGreen)

BilinearResize (Width, Height)
AudioDub (Last, Base)

Return ((Mode == 1) ? Last : Base).BilinearResize (Width, Height)

}

Here's a couple samples that I really liked

actionman133
17th January 2005, 03:50
btw, mode 1 produces the 'Predator heat vision', and mode 2 outputs the black & white footage.

trolltuning
17th January 2005, 15:12
Not useless- I can probably make some interesting intros to dance videos with your script.:cool:

actionman133
17th January 2005, 15:19
I'm actually improving it a little... I'm trying to work the white overexposure into it, and it adds a little texture to the blood red faces. It looks much better, but the only issue is that it seems to be quite slow.

I'd post the new script up, but it's not on this machine. Tomorrow, maybe...

E-Male
17th January 2005, 18:02
nice, i like it when people use avisynth for artistic pruposes, not only for scientific processing

actionman133
18th January 2005, 02:48
Here's the new and improved version that incorporates white into the 'hot' sections of the video, as promised. But as I said, it is very slow. Anyone who can find a way to improve the speed, it would be greatly appreciated.

For the sake of preserving the speed of the original function, if WhiteColour is false, it won't add white and simplify the operation.

Adding the white, does have a side effect though. The other colours seem to lose some integrity, and I'm at a loss as to how to correct it.

Any ideas?

Function Thermal (clip Last, int Mode, int Potency, bool "WhiteColour") {

Mode = (Mode >= 2) ? 2 : 1
Mode = (Mode <= 1) ? 1 : 2
WhiteColour = Default (WhiteColour, False)

Base = VtoY.Levels (128, 1, 255 - Potency, 0, 255)

Blue = Base.Levels (0, 1, 63, 192, 128)
Green = Base.Levels (64, 1, 95, 63, 0)
Yellow = Base.Levels (96, 1, 159, 127, 64)
Red = Base.Levels (160, 1, 228, 191, 255)
White = Base.Levels (229, 1, 255, 128, 255)

RedMask = Red.Levels (191, 1, 192, 0, 255)
BlueMask = Blue.Levels (128, 1, 129, 0, 255)
WhiteMask = White.Levels (191, 1, 192, 0, 255)

RedGreen = Overlay (Green, Red, mask = RedMask)
BlueYellow = Overlay (Yellow, Blue, mask = BlueMask)

Format = (IsYV12 == True) ? "YV12" : "YUY2"

RedGreen = (WhiteColour == True) ? Overlay (RedGreen, BlankClip (Red, pixel_type = Format, Color_yuv = $7F7F7F), mask = White.Levels (128, 1, 255, 0, 255)) : RedGreen
BlueYellow = (WhiteColour == True) ? Overlay (BlueYellow, BlankClip (Red, pixel_type = Format, Color_yuv = $7F7F7F), mask = White.Levels (128, 1, 255, 0, 255)) : BlueYellow

YtoUV (BlueYellow, RedGreen)
(WhiteColour == True) ? MergeLuma (Last, White.BilinearResize (Width, Height)) : Last

AudioDub (Last, Base)

Return ((Mode == 1) ? Last : Base.BilinearResize (Width, Height))

}