Add-Type -AssemblyName System.Drawing foreach ($n in 'home-green', 'ai-green', 'mine-green') { $bmp = [System.Drawing.Bitmap]::FromFile("d:\work\health\code\ws_health\ui\wxapp_escort\images\$n.png") $counts = @{} for ($x = 0; $x -lt $bmp.Width; $x += 2) { for ($y = 0; $y -lt $bmp.Height; $y += 2) { $p = $bmp.GetPixel($x, $y) if ($p.A -lt 128) { continue } $key = '{0},{1},{2}' -f $p.R, $p.G, $p.B $counts[$key] = [int]$counts[$key] + 1 } } $top = $counts.GetEnumerator() | Sort-Object Value -Descending | Select-Object -First 2 $line = ($top | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join ' ' Write-Host "$n : $line" $bmp.Dispose() }