Source/NFX/IO/ImageUtils.cs
/// <summary>
/// Extracts three main colors and background color from source image.
/// Does the same as <see cref="ExtractMainColors"/> method but performs the second extraction attempt if the first attempt returns almost the same colors
/// </summary>
/// <param name="srcBmp">Source image</param>
/// <param name="dwnFactor1">Main downgrade factor
/// (source image color quality reduced down to 256/<paramref name="dwnFactor1"/> color per each of RGB channel (2*2*2=8 base colors used as default))</param>
/// <param name="dwnFactor2">Secondary downgrade factor for inner-area main color selection</param>
/// <param name="interiorPct">Value within (0,1) range that indicates portion of image interior,
/// i.e. 0.9 means that 10% part of the image will be used for boundary detection</param>
/// <param name="imgDistEps">Color similarity factor. If less that specified value, then the second extraction attempt will be performed</param>
/// <returns>Three main colors and background volor</returns>
Extracts three main colors and background color from source image.
Does the same as  method but performs the second extraction attempt if the first attempt returns almost the same colors
Extracts three main colors and background color from source image . Does the same as method but performs the second extraction attempt if the first attempt returns almost the same colors
public static Color[] ExtractMainColors2Iter(Bitmap srcBmp,
                                                 int dwnFactor1=128, int dwnFactor2=24,
                                                 float interiorPct=0.9F,
                                                 float imgDistEps=0.2F)
    {
      var topColors = ExtractMainColors(srcBmp, dwnFactor1, dwnFactor2, interiorPct);
      var d12 = imagesAbsDist(topColors[0], topColors[1]);
      var d23 = imagesAbsDist(topColors[1], topColors[2]);
      if (d12<imgDistEps && d23<imgDistEps)
        topColors = ExtractMainColors(srcBmp, dwnFactor1/2, dwnFactor2, interiorPct);
      return topColors;
    }
public static Color [ ] ExtractMainColors2Iter ( Bitmap srcBmp , int dwnFactor1 = 128 , int dwnFactor2 = 24 , float interiorPct = 0.9F , float imgDistEps = 0.2F ) { var topColors = ExtractMainColors ( srcBmp , dwnFactor1 , dwnFactor2 , interiorPct ) ; var d12 = imagesAbsDist ( topColors [ 0 ] , topColors [ 1 ] ) ; var d23 = imagesAbsDist ( topColors [ 1 ] , topColors [ 2 ] ) ; if ( d12 < imgDistEps && d23 < imgDistEps ) topColors = ExtractMainColors ( srcBmp , dwnFactor1 / 2 , dwnFactor2 , interiorPct ) ; return topColors ; }
Extracts three main colors and background color from source image.
Extracts three main colors and background color from source image .
Three main colors and background volor
Three main colors and background volor
srcBmp
Bitmap
None
dwnFactor1
int
Main downgrade factor
(source image color quality reduced down to 256/ color per each of RGB channel (2*2*2=8 base colors used as default))
Main downgrade factor ( source image color quality reduced down to 256 / color per each of RGB channel ( 2 * 2 * 2 = 8 base colors used as default ))
dwnFactor2
int
Secondary downgrade factor for inner-area main color selection
Secondary downgrade factor for inner - area main color selection
interiorPct
float
Value within (0,1) range that indicates portion of image interior,
i.e. 0.9 means that 10% part of the image will be used for boundary detection
Value within ( 0 1 ) range that indicates portion of image interior i . e . 0 . 9 means that 10% part of the image will be used for boundary detection
imgDistEps
float
Color similarity factor. If less that specified value, then the second extraction attempt will be performed
Color similarity factor . If less that specified value then the second extraction attempt will be performed