필터 지우기
필터 지우기

How can i convert my specific color detection in rgb to hsv?

조회 수: 2 (최근 30일)
sibtain abbas
sibtain abbas 2017년 5월 31일
답변: David Szwer 2017년 6월 1일
i'm trying to convert this rgb code to hsv.
if((RGB(i,j,1)>140 && RGB(i,j,1)<165)&&(RGB(i,j,2)>120 && RGB(i,j,2)<140)&&(RGB(i,j,3)>85 && RGB(i,j,3)<110))% good match frame 25
I(i,j)=1;
end
if((RGB(i,j,1)>130 && RGB(i,j,1)<150)&&(RGB(i,j,2)>120 && RGB(i,j,2)<130)&&(RGB(i,j,3)>75 && RGB(i,j,3)<85))% good match frame 25
I(i,j)=1;
end

채택된 답변

David Szwer
David Szwer 2017년 6월 1일
There's an existing pair of functions hsv2rgb, and rgb2hsv, that should do exactly what you want. Just convert your image to rgb before your code, and back to hsv afterwards. Obviously it would me rather more efficient to rewrite your function to directly act on the hsv image, but without knowing your application we can't help with that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by