Function Repository Resource:

VideoColorMap

Source Notebook

Create a "color map" image from a video

Contributed by: Michael Sollami

ResourceFunction["VideoColorMap"][video]

creates an “color map” of the given video.

Details and Options

ResourceFunction["VideoColorMap"] works on color images as well as videos.
ResourceFunction["VideoColorMap"] takes the following options:
"Downsample"100factor by which to downsample raw pixels before clustering
"FrameCount"Allnumber of frames to use when calling VideoFrameList
"Parallel"Truecalculate image maps for each frame in parallel
ResourceFunction["VideoColorMap"] utilizes the resource function DynamicMap to show (parallel) processing progress.

Examples

Basic Examples (3) 

Create a color map of a video, using 50 frames:

In[1]:=
v = Video["ExampleData/Caminandes.mp4"];
cm = ResourceFunction["VideoColorMap"][v, "FrameCount" -> 50, "Downsample" -> 1000] // AbsoluteTiming
Out[1]=

Create a color map of a video using all frames (which could take a long time):

In[2]:=
v = Video["ExampleData/Caminandes.mp4"];
AbsoluteTiming[cm = ResourceFunction["VideoColorMap"][v]]

A color map of a single image is a 1-pixel wide vertical image:

In[3]:=
cm = ResourceFunction["VideoColorMap"]@
   ExampleData[{"TestImage", "Couple"}];
ImageDimensions[cm]
Out[3]=

Visualize a color maps for single images:

In[4]:=
Multicolumn[
 Labeled[Thumbnail[ExampleData[{"TestImage", #}], 100], ImageResize[
     ImageRotate[
      ResourceFunction["VideoColorMap"]@
       ExampleData[{"TestImage", #}]], {100, 20}]] & /@ {"Couple", "F16", "Flower", "RadcliffeCamera", "Sailboat", "Stall", "Tiffany",
    "Tree"}, 4]
Out[4]=

Options (2) 

Creating a color map of a video is time intensive, this can be sped up by increasing the "Downsample" factor (thus decreasing the height) or limiting the "FrameCount" (thus decreasing the width):

In[5]:=
v = Video["ExampleData/Caminandes.mp4"];
cm = ResourceFunction["VideoColorMap"][v, "FrameCount" -> 50, "Downsample" -> 2000] // AbsoluteTiming
Out[5]=

The process can also be sped up with the "Parallel" option:

In[6]:=
v = Video["ExampleData/Caminandes.mp4"];
cm = ResourceFunction["VideoColorMap"][v, "Parallel" -> True, "FrameCount" -> 500, "Downsample" -> 1000] // AbsoluteTiming
Out[6]=

Publisher

Michael Sollami

Requirements

Wolfram Language 12.1 (March 2020) or above

Version History

  • 1.0.0 – 18 February 2020

Related Resources

License Information