tree-ring detection !!!

7 views (last 30 days)
Taelee Kim
Taelee Kim on 8 Jul 2019
Edited: Metin EKEN on 18 May 2022
It's a binary picture of a wood disk.
1. Is there a way to detect the white and black boundaries?
2. I want to get rid of the black noise that exists in the white area.
is there any other way to make clearer binary image?
we use matlab.
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 8 Jul 2019
Have you tried with Morphological operation?
Taelee Kim
Taelee Kim on 9 Jul 2019
Yesss, i tried imerode, imdilate, imopen operation.
but, it doesn't work well.
Because, that image have scratches ( caused by sandpaper machine).
When morphological shape is bigger than 5, thin tree ring is discovered by Morphological shape.
plz...

Sign in to comment.

Accepted Answer

KSSV
KSSV on 9 Jul 2019
How about this approach?
I = imread('image.png') ;
I1 = imcrop(I) ; % cropping the required part
% imshow(I1)
I2 = rgb2gray(I1) ;
[y,x] = find(I2==0) ;
N = 15 ;
%% Get Bounding box
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
% length and breadth
L = abs(x1-x0) ;
B = abs(y1-y0) ;
% center bounding box
C = [x0+B/2 y0+L/2] ;
%% Get distances of the points from center of bounding box
data = repmat(C,[length(x),1])-[x,y] ;
dist = sqrt(data(:,1).^2+data(:,2).^2);
%% Classify the points into circles
nbins = 15 ; % number of circles you want
[N,edges,bin] = histcounts(dist,nbins) ;
% plot the classified circle points for check
figure(1)
imshow(I2)
hold on
for i = 1:nbins
plot((x(bin==i)),y(bin==i),'.','color',rand(1,3)) ;
end
%% Circle's radii and center
Circ = cell(nbins,1) ;
for i = 1:nbins
[xc1,yc1,R] = circfit(x(bin==i),y(bin==i)) ;
Circ{i} = [xc1 yc1 R] ;
end
figure(2)
imshow(I2)
hold on
th = linspace(0,2*pi) ;
for i = 1:nbins
xc = Circ{i}(1)+Circ{i}(3)*cos(th) ;
yc = Circ{i}(2)+Circ{i}(3)*sin(th) ;
plot(xc,yc,'color',rand(1,3),'linewidth',3) ;
end
  4 Comments
Image Analyst
Image Analyst on 10 May 2022
@Metin EKEN You can use this
%===========================================================================================================================================
function [xCenter, yCenter, radius, a] = circlefit(x, y)
% circlefit(): Fits a circle through a set of points in the x - y plane.
% USAGE :
% [xCenter, yCenter, radius, a] = circlefit(X, Y)
% The output is the center point (xCenter, yCenter) and the radius of the fitted circle.
% "a" is an optional output vector describing the coefficients in the circle's equation:
% x ^ 2 + y ^ 2 + a(1) * x + a(2) * y + a(3) = 0
% by Bucher Izhak 25 - Oct - 1991
numPoints = numel(x);
xx = x .* x;
yy = y .* y;
xy = x .* y;
A = [sum(x), sum(y), numPoints;
sum(xy), sum(yy), sum(y);
sum(xx), sum(xy), sum(x)];
B = [-sum(xx + yy) ;
-sum(xx .* y + yy .* y);
-sum(xx .* x + xy .* y)];
a = A \ B;
xCenter = -.5 * a(1);
yCenter = -.5 * a(2);
radius = sqrt((a(1) ^ 2 + a(2) ^ 2) / 4 - a(3));
end
Metin  EKEN
Metin EKEN on 18 May 2022
Edited: Metin EKEN on 18 May 2022
Thanks for recommends. Actualy I have a different problem. İ'm using various function to counting tree age rings, but results not good. Can you tell me, which function am ı use.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!