| [im_col]=getcolor(imh,h1,h2,s1,s2,v1,v2)
|
function [im_col]=getcolor(imh,h1,h2,s1,s2,v1,v2)
% [im_col]=getcolor(imh,h1,h2,s1,s2,v1,v2)
% im_col = returned image with desired color range
% imh = input image in hsv format
% h1 = hue start range if you want to cover greater than 0.8 and less than 0.2, basically for RED color, than enter -0.2
% h2 = hue end range
% s1 = saturation start range
% s2 = saturation end range
% v1 = value start range
% v2 = value end range
%
% For reference, Red, Green and Blue color can be fetched as below
% Hue ranges :
% Red -0.2 to 0.22
% Green 0.22 to 0.55
% Blue 0.55 to 0.8
% Syntax :
% imh=getcolor(imt,-0.2,0.22,0.20,1,0.20,1);
if h1<0
h1=1+h1;
h=or(imh(:,:,1)>=max(h1,h2),imh(:,:,1)<=min(h1,h2));
else
h=and(imh(:,:,1)<=max(h1,h2),imh(:,:,1)>=min(h1,h2));
end
s=and(imh(:,:,2)<=max(s1,s2),imh(:,:,2)>=min(s1,s2));
v=and(imh(:,:,3)<=max(v1,v2),imh(:,:,2)>=min(v1,v2));
mul=h&s&v;
mul=repmat(mul,1,3);
mul=reshape(mul,size(imh,1),size(imh,2),3);
im_col=imh.*mul;
|
|