tree-ring detection !!!

조회 수: 7 (최근 30일)
Taelee Kim
Taelee Kim 2019년 7월 8일
편집: Metin EKEN 2022년 5월 18일
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
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 8일
Have you tried with Morphological operation?
Taelee Kim
Taelee Kim 2019년 7월 9일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2019년 7월 9일
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
Image Analyst
Image Analyst 2022년 5월 10일
@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 2022년 5월 18일
편집: Metin EKEN 2022년 5월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by