I am pretty new to color image processing and now face the task of detecting colored skin markers like in the image below. In the cursory reading I've done, it seems like HSV and Lab are the color spaces of choice for distinguishing features based on color, but the reasoning why one would choose one over the other is not clear to me. My attempts so far have used HSV and I'm reasonably happy with the degree of segmentation accuracy I'm getting in the segmentation map to the right. It was generated using the function colorseghsv() below
imagesc(colorseghsv(A)); axis image off
However I'm wondering if Lab might be more appropriate or robust in this scenario for any reason. In this application, I will have a good deal of control over the lighting and color content of the image. For example, I've deliberately painted the markers in fluorescent colors to enhance them and that can always be made the case for all subjects.
I'm also wondering if there are more systematic ways of choosing thresholds for binning the color space coordinates. In my code below, the thresholds were chosen largely through a combination of trial and error and manually inspecting the HSV components of markers in a test image.
function segmap=colorseghsv(rgbImage)hsv=rgb2hsv(rgbImage); colors={'green','rose','blue','yellow','green'}; BW=false; for i=1:length(colors) BW=BW|markerbin(colors{i},hsv); end BW = imclose(BW,ones(5));for ii=3:-1:1 Q=regionprops(BW,rgbImage(:,:,ii),'MeanIntensity'); cmap(:,ii)=vertcat(Q.MeanIntensity)/255;endsegmap=label2rgb(bwlabel(BW),cmap,'k');function bw=markerbin(label,hsv) vthresh=.9; H=hsv(:,:,1); S=hsv(:,:,2); V=hsv(:,:,3); Vbin=V>=vthresh; switch label case 'blue' Hbin=abs(H-.55)<=.1; Sbin=S>=.5; case 'yellow' Hbin=abs(H-.16)<=.1; Sbin=S>=.5; case 'green' Hbin=abs(H-.325)<=.1; Sbin=S>=.5; case 'orange' Hbin=abs(H-.125)<=.025; Sbin=S>=.5; case 'rose' Hbin=abs(H-.85)<=.1; Sbin=S>=.5; end bw=Hbin&Sbin&Vbin;
Best Answer