Image Segmentation to obtain smallest particle

1 view (last 30 days)
How do I do segmentation to obtain smallest particle from a soil image?? I have used the following coding but its not giving accurate result. Please help. Thank you.
soil=imread('Example Image');
soil=rgb2gray(soil);
I_eq=adapthisteq(soil);
bw=im2bw(I_eq,graythresh(I_eq));
bw2=imfill(bw,'holes');
bw3=imopen(bw2,ones(5,5));
bw4=bwareaopen(bw3,40);
bw4_perim=bwperim(bw4);
mask_em=imextendedmax(I_eq,30);
I_eq_c=imcomplement(I_eq);
I_mod=imimposemin(I_eq_c,~bw4|mask_em);
L=watershed(I_mod);
cc = bwconncomp(L,8);
n= cc.NumObjects;

Answers (1)

Walter Roberson
Walter Roberson on 5 Jun 2017
That is a JPEG image. The smallest particle will probably be a single pixel, and you will have a heck of a time figuring out what is going wrong in your algorithm.
The short summary: never try to do scientific analysis on JPEG images -- not unless what you are trying to analyze is the operation of the JPEG algorithm itself.
  3 Comments
Walter Roberson
Walter Roberson on 5 Jun 2017
PNG or TIFF or BMP or DICOM.
I am fond of TIFF format; Image Analyst tends to favor PNG.
If you need to store multiple related images together, such as hyperspectral images, then TIFF or DICOM are designed for that, and PNG can be made to work for that, but not the other image formats.
Tinna Armasamy
Tinna Armasamy on 5 Jun 2017
I have tried in TIFF format, but still obtaining similar result. Is there any suggestion whether I have error in my coding itself or any other option I can try in Matlab?

Sign in to comment.

Categories

Find more on Image Processing Toolbox 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!