- 'imread' function: https://www.mathworks.com/help/matlab/ref/imread.html
- 'bwareaopen' function: https://www.mathworks.com/help/images/ref/bwareaopen.html
- 'regionprops' function: https://www.mathworks.com/help/images/ref/regionprops.html
How can I measure the (μm) length, diameter and radius of halloysite mineral?
1 view (last 30 days)
Show older comments
0 Comments
Accepted Answer
Balavignesh
on 1 Apr 2024
Hi Dilshod,
It seems like you would like to measure the length, diameter and radius of halloysite mineral. I assume you have an image saved in your directory named 'halloysite.jpg'.
The first step is to obtain a high-resolution, microscopic image of the halloysite particles using 'imread' function. Convert the image to grayscale (if it's an rgb image). Enhance the image to make the particles more distinguishable from the background. Then, you could get all the necessary statistics for the enhanced image using 'regionprops' function.
The following example code may help you achieve this functionality:
% Read the Image
img = imread('halloysite.jpg');
imshow(img);
title('Original Image');
% Preprocessing (example: convert to grayscale and enhance contrast)
if size(img, 3) == 3 % Check if the image is RGB
img_gray = rgb2gray(img);
else
img_gray = img;
end
img_enhanced = imadjust(img_gray);
figure;
title('Enhanced Image');
% Segmentation
bw = imbinarize(img_enhanced);
bw = bwareaopen(bw, 50); % Remove small objects from binary image
figure;
title('Segmented Image');
% Step 4: Particle Analysis
stats = regionprops('table', bw, 'MajorAxisLength','MinorAxisLength','EquivDiameter','Centroid');
% Step 5: Calculate Radius (assuming circular cross-sections for simplicity)
% The radius is half the diameter. Adjust calculations based on your understanding of particle shapes.
stats.Radius = stats.EquivDiameter / 2;
% Display the updated table with Radius
disp(stats);
% Note: For length and diameter, you might primarily rely on 'MajorAxisLength' and 'MinorAxisLength'.
% Adjust these based on your specific needs and understanding of the halloysite particles' geometry.
You will obtain a table of results something similar to this :
Kindly have a look at the following documentation links to have more information on:
Hope this helps!
Balavignesh
2 Comments
Image Analyst
on 18 Apr 2024
As you've discovered by now, the accepted answer doesn't find the particles. I've added the missing lines to show you the particles this algorithm found. But SEM images are notoriously difficult to automatically segment and for this image I think you'd be better off doing it manually. I'll give you some examples in my separate answer later.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
markerSize = 20;
%-----------------------------------------------------------------------
% Read the Image
img = imread('Dilshod.jpeg');
subplot(2, 2, 1);
imshow(img);
title('Original Image');
drawnow;
impixelinfo;
%-----------------------------------------------------------------------
% Preprocessing (example: convert to grayscale and enhance contrast)
if size(img, 3) == 3 % Check if the image is RGB
img_gray = rgb2gray(img);
else
img_gray = img;
end
% Crop off image info along bottom
img_gray = img_gray(1:885, :);
img_enhanced = imadjust(img_gray);
subplot(2, 2, 2);
imshow(img_enhanced);
title('Enhanced Image');
drawnow;
impixelinfo;
%-----------------------------------------------------------------------
% Segmentation
bw = imbinarize(img_enhanced);
bw = bwareaopen(bw, 50); % Remove small objects from binary image
subplot(2, 2, 3);
imshow(bw);
title('Segmented Binary Image');
drawnow;
impixelinfo;
%-----------------------------------------------------------------------
% Label each blob with 8-connectivity, so we can make measurements of it
[labeledImage, numberOfBlobs] = bwlabel(bw, 8);
% Apply a variety of pseudo-colors to the regions.
coloredLabelsImage = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
% Display the pseudo-colored image.
subplot(2, 2, 4);
imshow(coloredLabelsImage);
caption = sprintf('Segmented Labeled Image with %d blobs', numberOfBlobs)
title(caption);
drawnow;
%-----------------------------------------------------------------------
% Step 4: Particle Analysis
stats = regionprops('table', bw, 'MajorAxisLength','MinorAxisLength','EquivDiameter','Centroid');
%-----------------------------------------------------------------------
% Step 5: Calculate Radius (assuming circular cross-sections for simplicity)
% The radius is half the diameter. Adjust calculations based on your understanding of particle shapes.
stats.Radius = stats.EquivDiameter / 2;
% Display the updated table with Radius
disp(stats);
% Note: For length and diameter, you might primarily rely on 'MajorAxisLength' and 'MinorAxisLength'.
% Adjust these based on your specific needs and understanding of the halloysite particles' geometry.
Using major and minor axes lengths would not be appropriate for these particles since that fits an ellipse to the particles and your particles are nowhere near elliptical. Also, imadjust is not necessary.
More Answers (1)
Image Analyst
on 18 Apr 2024
Since most particles do not lie completely in the image or have one end obscured if they do, you can't get particle length. I suggest you manually drawlines across the particles and manually measure the blobs. I'm attaching some generic demos about drawing lines and spatially calibrating so that you can convert the distances to microns.
0 Comments
See Also
Categories
Find more on Fluid Dynamics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!