I need to count cell nucleus in these images how can I do that

5 次查看(过去 30 天)
Can I get a code in image processing field to count the cells’ nucleus from these photos

回答(1 个)

Vinayak Agrawal
Vinayak Agrawal 2023-6-15
Hi Asia,
Yes, here is an example code in MATLAB for counting the cells' nucleus from a JPEG photo:
% Load the image
img = imread('cells.jpg');
% Convert the image to grayscale
grayimg = rgb2gray(img);
% Apply a median filter to remove noise
medimg = medfilt2(grayimg);
% Enhance contrast using histogram equalization
equalizedimg = histeq(medimg);
% Segment the image using adaptive thresholding
thresimg = adaptthresh(equalizedimg, 0.3);
binaryimg = imbinarize(equalizedimg, thresimg);
% Remove small objects from the binary image
binaryimg = bwareaopen(binaryimg, 10);
% Find the connected components in the binary image
cc = bwconncomp(binaryimg);
% Count the number of cells' nucleus
nucleusCount = cc.NumObjects;
% Display the results
figure;
subplot(2,2,1); imshow(img); title('Original Image');
subplot(2,2,2); imshow(medimg); title('Grayscale Image with Median Filtering');
subplot(2,2,3); imshow(equalizedimg); title('Contrast Enhanced Image');
subplot(2,2,4); imshow(binaryimg); title(['Detected Nuclei: ', num2str(nucleusCount)]);
You may need to adjust the parameters of the image processing functions and methods used in this code to obtain the desired results for your input image. Also, note that this code assumes a certain level of expertise in image processing and MATLAB programming
Hope it helps

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by