How do i threshold blue colors in Simulink?

50 visualizaciones (últimos 30 días)
Erçin
Erçin el 6 de En. de 2012
I am working on RGB signals. I set From Video Device Block to Seperate Signals RGB. I need to detect blue colors. How do i threshold blue signal? I am trying to execute on only blue pixels. Thank you...

Respuestas (3)

Walter Roberson
Walter Roberson el 6 de En. de 2012
Is (0,0,255) "blue"? Probably. Okay, how about (0,0,0)? (0,0,1) ? (1,0,255) ?
You need to define what "blue" means for your purposes before you can go ahead.
  2 comentarios
Erçin
Erçin el 6 de En. de 2012
I need (0,0,X). X must be defineable by me. Ex: (0,0,200)
Erçin
Erçin el 6 de En. de 2012
Setting with Autothreshold block? I don't understand Autotreshold block settings.

Iniciar sesión para comentar.


Erçin
Erçin el 6 de En. de 2012
Red and Green isn't important for me cause of seperating signals and working on blue only. After the thresholding i will process with that blue image.
  1 comentario
Erçin
Erçin el 6 de En. de 2012
I need high blue is 1, low blue is 0 threshold. It means converting image to BW image.

Iniciar sesión para comentar.


Jonathan Sullivan
Jonathan Sullivan el 6 de En. de 2012
Perhaps I might suggest something else. I don't believe you want to threshold based an the absolute amount of blue present in a pixel, but rather based off of the relative amount of blue compared to red and green.
Let's look at a few different colors:
c1 = [0 0 255];
c2 = [255 0 255];
c3 = [20 20 255];
c4 = [0 0 128];
I would venture to guess that c1, c3, and c4 are all "blue" enough, while c2 is certainly not what you are looking for. Think of the color of a pixel being a vector in a 3 dimensional space. What you want to do is find the angle of the color vector of the pixel to the color vector of the ideal by using the dot product.
For example:
blue = [0 0 255];
pixel = [10 10 200];
ang_thres = 25; % degrees. You should change this to suit your needs
ang = acosd(dot(blue/norm(blue),pixel/norm(pixel)));
isBlue = ang <= ang_thres; % Apply angle threshold
You might also want to apply a magnitude threshold (i.e. is the pixel dark enough). This would filter out any really faint colors (i.e. [0 0 1]);
For example:
blue = [0 0 255];
pixel = [10 10 200];
ang_thres = 25; % degrees. You should change this to suit your needs
ang = acosd(dot(blue/norm(blue),pixel/norm(pixel)));
mag_thres = 64; % You should change this to suit your needs
mag = norm(pixel);
isBlue = ang <= ang_thres & mag >= mag_thres; % Apply both thresholds
Hope this helps!
  2 comentarios
Erçin
Erçin el 6 de En. de 2012
I had thought similar algorithms but my purpose is doing it with Simulink. Because i will process a video in a physic system and need speed to. So needed embedded functions. Thank you by the way...
Jonathan Sullivan
Jonathan Sullivan el 9 de En. de 2012
I'm not too familiar with Simulink, but this is how it would be done in MATLAB. I hope you can find a solution that suites your needs.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by