Color detection in an image and mathematical formula
Hello, I have a question, I have done the color detection in an image with python and opencv, but they tell me that there are different ways and that I apply the others together with a mathematical formula, but I can not find anything, someone can help me
I am not getting your question. Explain your question in detail.
ok, I use the following to detect a color in an image, but I need to know what formula is based on the code, does anyone know?
import cv2 import numpy as np
imagen = cv2.imread('entrada/9.jpg') imagen2 = cv2.resize(imagen, (1280,680))
Mis colores
cafes_bajos = np.array([60,70,99], dtype=np.uint8) cafes_altos = np.array([21,57,71], dtype=np.uint8) mask = cv2.inRange(imagen2, cafes_altos, cafes_bajos) ingray = cv2.bitwise_and(imagen2,imagen2, mask= mask) cv2.imshow('Grises', ingray) cv2.imshow('Imagen', imagen2) cv2.imshow('Final', mask)
Salir con ESC
while(1): tecla = cv2.waitKey(5) & 0xFF if tecla == 27: break
cv2.destroyAllWindows()
Let assume you have RGB image. here you are finding minimum and maximum intensities values of R,G,B channel for object you have to segment/threshold from image. after that you go to every pixels in a image an check does that pixel value lies in the range, if its lies in the range then you will assign that pixel with 255 else 0. sample code in matlab does that.
rchannel = image[:,:,0] gchannel = image[:,:,1] bchannel = image[:,:,2]
thresholded =bchannel > bLow & bchannel< bHigh & gchannel > gLow & gchannel <ghigh &="" rchannel="" >="" rlow="" &="" rchannel="" <="" rhigh="" <="" p="">
I hope this is want you want.
suppose we have a formula with this we deduce that we come to a solution, I know that for image processing are based on formulas, but I do not know what is the formula that applies to what I already do
What mathematical formula is used in image processing?
tanks........