필터 지우기
필터 지우기

How can I define red color in HSV space

조회 수: 10 (최근 30일)
THUONG NGUYEN VAN
THUONG NGUYEN VAN 2013년 5월 4일
댓글: Image Analyst 2013년 11월 10일
I have problem when using webcam to detect and track object by masking colors in HSV space. my code work well with yellow, green or blue color but red color.
I already define the threshold for these colors
please help me.
here is my code
% red
hueThresholdLowred1 = 0.05; hueThresholdHighred1 = 0.97;
saturationThresholdLowbred1 = 0.3; saturationThresholdHighred1 = 1;
valueThresholdLowred1 = 0.01; valueThresholdHighred1 = 1;
% find red color
hueMaskred1 = (hImage1 <= hueThresholdLowred1)&(hImage1 >= hueThresholdHighred1);
saturationMaskred1 = (sImage1 >= saturationThresholdLowbred1) & (sImage1 <= saturationThresholdHighred1);
valueMaskred1 = (vImage1 >= valueThresholdLowred1) & (vImage1 <= valueThresholdHighred1);
redObjectsMask1 = hueMaskred1 & saturationMaskred1 & valueMaskred1;

채택된 답변

Walter Roberson
Walter Roberson 2013년 5월 4일
It is not possible for a number to be both less than 0.05 and greater than 0.97. Your statement
hueMaskred1 = (hImage1 <= hueThresholdLowred1)&(hImage1 >= hueThresholdHighred1);
is wrong (at least in terms of the values you set for those thresholds.)
Are you looking for values that are between 0.97 and 1, together with values that are between 0 and 0.05 ? Sounds like a narrow range to me, but if it is what you are looking for, change the "&" to "|"
  댓글 수: 3
aldi
aldi 2013년 11월 10일
how define green object on live webcam ? please code..
Image Analyst
Image Analyst 2013년 11월 10일
See several color segmentation demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Feel free to modify any of them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by