View full-text article in PMC Sensors (Basel). 2025 Jun 5;25(11):3572. doi: 10.3390/s25113572 Search in PMC Search in PubMed View in NLM Catalog Add to search Copyright and License information © 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/). PMC Copyright notice Algorithm A3 Calculates the predominant color in a masked region 1:function predominant_color( image , mask , label_to_segment ) 2: if label_to_segment∉mask then 3: raise ValueError 4: end if 5: mask_segment←(mask==label_to_segment) 6: masked_image←image[mask_segment] 7: masked_image_reduced←(masked_image//32)∗32 8: (colors,count)←np.unique(masked_image_reduced.reshape(−1,3),axis=0,return_counts=True) 9: predominant_color_rgb←colors[count.argmax()] 10: return get_color_name( tuple(predominant_color_rgb) ) 11:end function