Platforms to show: All Mac Windows Linux Cross-Platform

Back to Picture class.

Picture.ColornessMBS(threshold as Integer = 10) as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 12.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates the color coverage of the picture.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test.png")
dim pic as Picture = Picture.Open(file)

MsgBox str(pic.ColornessMBS)

Counts how many pixels have color and returns percentage depending on a given threshold.
Changed in 12.3pr5 to ignore nearly black pictures when counting.

This function loops over all pixels to calculate the difference between green and red channel and green and blue channel. If the differences are greater than the threshold, the pixel counts as colored.

Threshold is between 0 and 255. The value of 10 makes sure almost gray pictures don't count as colored ones.

Finally we calculate the percentage of colored pixels vs total pixels.

Blog Entries

The items on this page are in the following plugins: MBS Picture Plugin.


The biggest plugin in space...