# Color-Based Season Classifier

Build a classifier to separate images of the four seasons, based on the dominant colors available in images of each season, using the new built-in region operations.

Some public domain images are the source of the seasons' colors.

The images have different color distributions, but describing them is not easy in the RGB space.

 Out[71]=

In the Lab space, the hues are easily separable from the luminance.

 Out[72]=

A convex hull is defined from the distribution of the dominant colors for each season with the function ConvexHullMesh.

 Out[2]=

Define a distance function from a set of colors to a region using the new RegionDistance function.

 In[3]:= XEnsembleColorDistance[colors_] := With[ {\[Alpha] = 5, \[Beta] = 1/2}, Mean[Transpose[\[Alpha] #1 + (1 - Sign[#1]) \[Beta] #2]] & @@ ( Outer[RegionDistance[#, #2] &, #, colors, 1] & /@ {regionInside, regionOutside}) ]

The predicted season is the one that minimizes this distance.

 In[4]:= XSeasonClassifier[image_, n_: 16] := With[{colors = List @@@ DominantColors[image, n, "LABColor"][[All, {2, 3}]]}, Flatten@Position[#, Min[#]] /. Thread[Range[4] -> seasonsNames] &[ EnsembleColorDistance[colors]]]

Test the classifier on the remaining images.

 Out[5]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »