Info
This question is closed. Reopen it to edit or answer.
error with the function of hsv code..please help
1 view (last 30 days)
Show older comments
function [im_col]=gethsvcolour(circle,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;
this code is not working...the error " function [im_col]=getcolor(circle,h1,h2,s1,s2,v1,v2) | Error: Function definitions are not permitted in this context."
can somebody help me understand how i can make this code work to get a image overall red, blue and green in hsv values...
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!