How to use matlab to count these particles?
44 次查看(过去 30 天)
显示 更早的评论
So I have some neurospheres in a dish.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167682/image.jpeg)
After I take these images, I run them through imagej. I sharpen the picture, "despeckle" the image, add a guassian blur, and then find the edges of the image. The end result of that process looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167685/image.jpeg)
After this process, I take the image and run it through matlab's thresholding. The image then looks like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167687/image.jpeg)
Now I'd like to use some surface mapping and create peaks and valleys and count my neurospheres. The process I want to do is similar to the process found here.
I'd like to be able to count my neurospheres, come up with an area for each one, and then also have a diameter, and be able to discriminate each sphere by a minimum size diameter.
Would anyone be able to help?
Thanks,
Tushar The Ohio State University
2 个评论
Image Analyst
2022-6-27
@Bani Antonio Aguirre here is mine for interactive thresholding:
I'm also attaching a triangle threshold which is good for skewed histograms.
采纳的回答
Image Analyst
2017-9-29
编辑:Image Analyst
2017-9-29
You might try adapthisteq() or imbothat() to get an image of the spheres. Then threshold to get your segmented image. Anyway, once you have an image you can threshold, just threshold it and call regionprops(). I don't think you have to do anything with "surface mapping and create peaks and valleys". Not sure what you were thinking there. So, basically
binaryImage = filteredImage < someThresholdValue;
% Measure areas and diameters.
props = regionprops(binaryImage, 'Area', 'EquivDiameter');
% Get measurements from structure into 1-D array
allAreas = [props.Area];
allDiameters = [props.EquivDiameter];
% Histogram them (will plot into current axes - create a new axes if you don't want that).
histogram(allAreas);
grid on;
% Sort from largest diameter to smallest, if you want (optional).
[sortedDiams, sortOrder] = sort(allDiameters, 'Descend');
% Sort areas the same way so they are kept matched up (together).
sortedAreas = allAreas(sortOrder);
See my File Exchange for a full demo in my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
I don't know what "discriminate each sphere by a minimum size diameter" means. The code above finds all blobs. If you want to throw out some and keep only some in a certain size range, call bwareafilt() or bwareaopen() before you call regionprops().
6 个评论
Ham Man
2021-10-25
Hello evry one
I'm beginner and I have a picture as below and i want to count the particles in this image using matlab.
What is a simple script to run this.
Appreciate your help!![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/778143/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/778143/image.jpeg)
更多回答(1 个)
John BG
2017-10-1
编辑:John BG
2017-10-1
Hi Tushar
1.- Acquiring petri image, using green layer only, manually binarising the whole image.
Play with threshold th1
clear all;clc;close all
A=imread('blood_cells_count.jpg');
% A2=A(:,:,1)+A(:,:,2)+A(:,:,3); % a bit more contrast
A2=A(:,:,2); % since green marker used no need for red blue layers
th1=190;
A2(A2>th1)=255;
A2(A2<th1)=0;
figure(1);imshow(A);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178472/image.jpeg)
figure(2);imshow(A2);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178473/image.jpeg)
.
2.- Filling up holes in binarised cells
A20=~A2;
area_threshold=6;
A21 = bwareaopen(A20,area_threshold);
figure(10);imshow(A21);
A22=imfill(A21, 'holes');
figure(11); imshow(A22);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178474/image.jpeg)
.
3.- It may not be really needed, but just in case, filling up and plotting cell contours
[B,L] = bwboundaries(A22,'noholes');
map=zeros(length(B),3);cmap=colormap(map);
figure(12);imshow(label2rgb(L,cmap, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 1)
end
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178475/image.jpeg)
.
4.- The asked cells count is:
length(B)
ans =
398
.
5.- Add a halo around each binarised blood cell, neurons are hairy aren't they?
PSF = fspecial('gaussian',5,5);
A3 = deconvlucy(uint8(255*(~A21)),PSF,5);
figure(3);imshow(A3);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178476/image.jpeg)
.
Comment:
using area threshold may remove a few small cells. Sample arrowed small specks are removed but the circled small cell is also removed.
Perhaps next step would be to consider removing small AND no green marker (dark only) specks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178477/image.jpeg)
.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
3 个评论
John BG
2017-10-1
Tushar
the last image with the arrows and the circled cell is BEFORE removing the specs.
In the resulting image, black cells with red skin, the specks have already been removed.
Or in the resulting image with halos around cells, there are no small specs, they were removed.
The image was just a closing comment.
The next steps would be, from :
- number the cells
- measure the area of each cell using each boundary B{k}
- colour the cells according respective areas
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!