Okay, could you specify the exact problem you are facing?
If I understand correctly, you want to first segment the cells (based on color). Then, in the second step, classify these objects (cells) based on their color. Is this correct?
I too work with images of cells (stained using immunohistochemistry). Some cells are stained brown, while others are stained blue. In my case, I just have to segment the brown-stained cells and the blue-stained cells, which requires separation of the colors (stains) as the first step.
yes,exactly , i want to do as you specified here. i have cells stained with pink, blue,orange. i want to segment them and display label on the cells specified by their respective color. am successful in segmentation, but in labelling am finding difficulty, bwlabel function works on binary image. but am using RGB image.
Ah, gotcha! The problem seems to be with overlaying the segmentation on the original image, is that correct?
Once you have the binary mask for the segmentation, convert it to a label image and then to an RGB image -
labelImg = bwlabel(bwImg);
labelImgRgb= label2rgb(labelImg);
It can be displayed on the original image using -
figure, imshow(origImg);
hold on;
himage = imshow(labelImgRgb);
himage.AlphaData = 0.5; %set transparency
However, labelImgRgb will have a unique color for each cell. If you want three groups of cells and each group colored with the same color, you will need three different binary images, one per group of cells, and a color map for each. Then, you basically have to do the operation three times -
[labelImg1, n1] = bwlabel(bwImg1);
map1 = repmat([1 0.75 0.8], n1, 1); %rgb for pink - same for all objects
labelImgRgb1= label2rgb(labelImg1, map1);
%% repeat this with bwImg2, and bwImg3 with different maps %%
...
%%
Then overlay each label RGB image on the original image as earlier.
You can change the RGB vector array in the map to anything you want. The MATLAB documentation for label2rgb() will be more helpful here.
Now, if you want to change the actual pixel values of the original image to specific colors, then you don't even need to get the label image. All you need to do is use the binary images as logical indices into the original image to replace the pixel values with the color you want.
can you please tell me how to draw arc through three points where coordinates , acute angle at point is known, i want to draw arc in both clockwise and anti-clockwise direction. Thanks in advance.