79812802

Date: 2025-11-07 21:36:44
Score: 0.5
Natty:
Report link

Another approach could be :

  1. Isolate the ROI
  2. Resize it to a very small scale
  3. Blur by using the whole size of the thumbnail
  4. Take the RGB value of the point crossing the bissectors

This way you avoid calculating an average RGB or HSV value, which is always problematic.

import numpy as np
import sys
import cv2

IMG="your_img.jpg"
   
def show_wait_destroy(winname, img):   
    cv2.imshow(winname, img)
    cv2.moveWindow(winname, 500, 0)
    cv2.waitKey(0)
    cv2.destroyWindow(winname)
    
def get_dominant_color(p_img, p_ksize):
    src = cv2.imread(p_img)
    src=cv2.resize(src, (p_ksize,p_ksize), interpolation=cv2.INTER_LINEAR)    
    show_wait_destroy('',src)
    blur = cv2.blur(src,(p_ksize,p_ksize))
    show_wait_destroy('',blur)
    k = blur[int(p_ksize/2),int(p_ksize/2)]
    return k   
       
def main(p_img):
    (b,g,r)=get_dominant_color(p_img,50)
    print(r,g,b)
       
main(IMG)

Source image :

Source image

Thumbnail/ROI :

Thumbnail

Blurred thumbnail :

enter image description here

"dominant RGB code" : 214 196 179

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Franck Theeten