Hey,
I have a rather noisy image with stained nuclei of cells. I want to detect single nuclei and then recognize their center.
I'm quite new to image processing, I've read through a bunch of cell detection posts.
The one I found especially useful:
http://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/
I completely understand what he does and my code is pretty much the same so far, besides that I adjusted parameters:
clear;
close all;
I = imread('Captured DAPI 20x 1.jpg');
figure, imshow(I),title('I')
Igray=I(:,:,3);
figure, imshow(Igray)
%I_eq = adapthisteq(Igray);
%figure, imshow(I_eq), title('I_eq')
I_eq=Igray;
bw = im2bw(I_eq, graythresh(I_eq));
figure, imshow(bw)
bw2 = imfill(bw,'holes');
figure, imshow(bw2)
bw3 = imopen(bw2, ones(5,5));
figure, imshow(bw3)
bw4 = bwareaopen(bw3, 40);
figure, imshow(bw4)
bw4_perim = bwperim(bw4);
figure, imshow(bw4_perim)
overlay1 = imoverlay(I_eq, bw4_perim, [.3 1 .3]);
figure, imshow(overlay1)
mask_em = imextendedmax(I_eq, 15);
figure, imshow(mask_em)
mask_em = imclose(mask_em, ones(5,5));
figure, imshow(mask_em)
mask_em = imfill(mask_em, 'holes');
figure, imshow(mask_em)
mask_em = bwareaopen(mask_em, 40);
figure, imshow(mask_em)
overlay2 = imoverlay(I_eq, bw4_perim | mask_em, [.3 1 .3]);
figure, imshow(overlay2)
I_eq_c = imcomplement(I_eq);
I_mod = imimposemin(I_eq_c, ~bw4 | mask_em);
L = watershed(I_mod);
figure, imshow(label2rgb(L))
figure, imshow(I_eq), hold on
himage = imshow(label2rgb(L));
set(himage, 'AlphaData', 0.3);
title('Lrgb superimposed transparently on original image')
Especially important is the mask line:
mask_em = imextendedmax(I_eq, 15);
The Problem I have is if I lower the second parameter too much, I'll get a lots of point that I don't want and are mostly due to noise. But with the current setting it doesn't find a maxima region in every cell.
Does anybody have a good idea how to improve the mask for the watershed so I'll detect all my cells individually?
Here are some pictures for you to see what I mean:
starting image: [IMG]http://imageshack.us/a/img43/3669/captureddapi20x1.jpg[/IMG]
watershed: [IMG]http://imageshack.us/a/img839/8830/watershed.jpg[/IMG]
watershed overlay: [IMG]http://imageshack.us/a/img853/8989/watershedoverlay.jpg[/IMG]
I have a rather noisy image with stained nuclei of cells. I want to detect single nuclei and then recognize their center.
I'm quite new to image processing, I've read through a bunch of cell detection posts.
The one I found especially useful:
http://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/
I completely understand what he does and my code is pretty much the same so far, besides that I adjusted parameters:
clear;
close all;
I = imread('Captured DAPI 20x 1.jpg');
figure, imshow(I),title('I')
Igray=I(:,:,3);
figure, imshow(Igray)
%I_eq = adapthisteq(Igray);
%figure, imshow(I_eq), title('I_eq')
I_eq=Igray;
bw = im2bw(I_eq, graythresh(I_eq));
figure, imshow(bw)
bw2 = imfill(bw,'holes');
figure, imshow(bw2)
bw3 = imopen(bw2, ones(5,5));
figure, imshow(bw3)
bw4 = bwareaopen(bw3, 40);
figure, imshow(bw4)
bw4_perim = bwperim(bw4);
figure, imshow(bw4_perim)
overlay1 = imoverlay(I_eq, bw4_perim, [.3 1 .3]);
figure, imshow(overlay1)
mask_em = imextendedmax(I_eq, 15);
figure, imshow(mask_em)
mask_em = imclose(mask_em, ones(5,5));
figure, imshow(mask_em)
mask_em = imfill(mask_em, 'holes');
figure, imshow(mask_em)
mask_em = bwareaopen(mask_em, 40);
figure, imshow(mask_em)
overlay2 = imoverlay(I_eq, bw4_perim | mask_em, [.3 1 .3]);
figure, imshow(overlay2)
I_eq_c = imcomplement(I_eq);
I_mod = imimposemin(I_eq_c, ~bw4 | mask_em);
L = watershed(I_mod);
figure, imshow(label2rgb(L))
figure, imshow(I_eq), hold on
himage = imshow(label2rgb(L));
set(himage, 'AlphaData', 0.3);
title('Lrgb superimposed transparently on original image')
Especially important is the mask line:
mask_em = imextendedmax(I_eq, 15);
The Problem I have is if I lower the second parameter too much, I'll get a lots of point that I don't want and are mostly due to noise. But with the current setting it doesn't find a maxima region in every cell.
Does anybody have a good idea how to improve the mask for the watershed so I'll detect all my cells individually?
Here are some pictures for you to see what I mean:
starting image: [IMG]http://imageshack.us/a/img43/3669/captureddapi20x1.jpg[/IMG]
watershed: [IMG]http://imageshack.us/a/img839/8830/watershed.jpg[/IMG]
watershed overlay: [IMG]http://imageshack.us/a/img853/8989/watershedoverlay.jpg[/IMG]