# qualpal::analyzePalette

C++ · 4.1.0

[Source](<https://github.com/jolars/qualpal/blob/887b793a3795d298a62e49356a72314ce59dab0d/include/qualpal/analyze.h>)

```cpp
PaletteAnalysisMap analyzePalette(const std::vector<colors::RGB> & colors, const metrics::MetricType & metric = metrics::MetricType::CIEDE2000, const std::map<std::string, double> & cvd = { { "deutan", 1.0 }, { "protan", 1.0 }, { "tritan", 1.0 } }, const std::optional<colors::RGB> & bg = std::nullopt, double max_memory = 1.0)
```

Analyze a color palette for normal and simulated color vision deficiencies (CVD). 

Computes color difference matrices and minimum color distances for the input palette, for normal vision as well as common color vision deficiencies ("deutan", "protan", "tritan") at the specified severity. Results are returned as a map keyed by vision type.

For each vision type:

- Simulates the palette (and optional background) under the specified CVD severity.
- Computes the pairwise color difference matrix using the selected metric.
- Computes the minimum distance to any other color for each palette color.
- Computes the minimum distance from the background (if provided) to the palette.

<a id="documentation-parameters"></a>

### Parameters

**`colors`**

Vector of RGB colors to analyze. Each channel should be in \[0, 1\]. 

**`metric`**

Color difference metric to use (e.g., CIEDE2000, DIN99d, CIE76). 

**`cvd`**

Map of CVD type ("deutan", "protan", "tritan") to severity \[0, 1\]. If a type is omitted or severity is 0, simulation is skipped for that type. 

**`bg`**

Optional background color to include in the analysis (RGB in \[0, 1\]). 

**`max_memory`**

Maximum memory (in GB) allowed for the difference matrix computation. 

 

<a id="documentation-returns"></a>

### Returns

Map from vision type string to [PaletteAnalysis](<48abc282d551e6a18307d2c0f6617fb4ec8ee540c2e3eb09b2fc9afaf651a6d5>) for each simulated vision.

 

<a id="documentation-throws"></a>

### Throws

**`std::invalid_argument`**

if input parameters are invalid.

 

<a id="documentation-see-also"></a>

### See also

[PaletteAnalysis](<48abc282d551e6a18307d2c0f6617fb4ec8ee540c2e3eb09b2fc9afaf651a6d5>), [PaletteAnalysisMap](<e554f5f39120510e90b4f32f0d8366a4a858bf1a1b3787443bf47ffeee6bcfb6>)
