How can I combine the HSV thresholding for 2 range color

조회 수: 2 (최근 30일)
SP
SP 2020년 8월 18일
답변: Elif Ozkan 2022년 3월 14일
Hello everyone
I would like to ask the question that how can I combine the two HSV color thresholiding ? Now, I use color thresholding in apps of matlab. Then I use HSV thresholding to threshold white hand and black hand. I would like to detect the hands both black and white but I don't know the way to combine 2 HSV color thresholding.
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.000;
channel1Max = 1.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.000;
channel2Max = 1.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 0.600;
..............................................................................................................................................................................................................................................
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.000;
channel1Max = 1.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.060;
channel2Max = 1.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 0.805;
Assume I threshold for black hand and white hand (the first is black and the second is white). I woud like to ask how can I combine it ?
Thank you for you answer.

답변 (1개)

Elif Ozkan
Elif Ozkan 2022년 3월 14일
Hello Sp,
I hope this is not too late. I assume you use SliderBW for thresholding. Black and white gives you two different image, lets say sliderBW_white and sliderBW_black. I am using "imadd".
% I is your HSV image
% use your white thresholds here
sliderBW_white = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
% use black threshold here
sliderBW_black = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
wholeImage = imadd(sliderBW_white, sliderBW_black); % black and white image in one image

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by