Gman Gman - 7 months ago 10
Python Question

what is the simple way to find the color of main object in an image

I am developig a vehicle color identifier.The image frame is always 400*300 size.and the vehicle is always at center.How to get the colour of that vehicle only.If vehicle is red it must output red.

Answer

If the image size is fixed and If you are sure about its position.You can use

crop_img = img[50:150, 100:200]

to crop a square from center.Then you can find its RGBA value and from RGBA value you can find its colour.

Comments