How to differentiate between two attached images with 25 sand particles in each image. I have successfully calculated circularity of particles in images. Average value is similar for both samples. Please guide to how differentiate between two sands?
2 views (last 30 days)
Show older comments
% The sand1 and sand2 images used are attached. In order to remove the noise in images median filter will variable rectangle window is used.
% for sand1 bw = medfilt2(bw, [30 30]);
% for sand2 bw = medfilt2(bw, [12 12]);
% rectangle threshold is fixed when the noise just disappears.
% An important to note is that with change in this window the circularity changes. How to deal with this ???????
clear all;
close all;
clc;
RGB = imread('sand1.jpg');
I = rgb2gray(RGB);
bw = imbinarize(I);
bw = bwareaopen(bw, 35);
se = strel('disk', 2);
bw = imclose(bw, se);
bw = imfill(bw, 'holes');
bw = medfilt2(bw, [12 12]);
[B, L] = bwboundaries(bw, 'noholes');
numberOfBoundaries = size(B, 1);
imshow(bw);
hold on;
for k = 1 : numberOfBoundaries
thisBoundary = B{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'R', 'LineWidth', 2);
hold on;
end
hold off;
stats = regionprops(L, 'Area');
for k = 1:length(B)
thisBoundary = B{k};
% computing perimeter
delta_sq = diff(thisBoundary).^2;
perimeter = sum(sqrt(sum(delta_sq,2)));
area = stats(k).Area;
% computing circularity
circularity(k) = 4*pi*area/perimeter^2;
end
4 Comments
KALYAN ACHARJYA
on 23 May 2019
Please correct me, If I misundestood the question.
You want to check wheather the both image are same or not (simmilarity)?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!