필터 지우기
필터 지우기

Histogram error at euclidian distance

조회 수: 1 (최근 30일)
Theodora Chivu
Theodora Chivu 2020년 5월 8일
답변: Image Analyst 2020년 5월 8일
Operator '-' is not supported for operands of type 'matlab.graphics.chart.primitive.Histogram'.
Dist1(i) = sqrt(sum((h1-h(i)).^2));
Both h are histogram objects.

채택된 답변

Image Analyst
Image Analyst 2020년 5월 8일
I'm pretty sure someone already answered this today for you and told you that you need to get the bin counts. Look what happens if you leave off the semicolon -- you get an object with all kinds of properties on it:
>> h1 = histogram(rand(1, 1000))
h1 =
Histogram with properties:
Data: [1×1000 double]
Values: [95 93 86 107 101 114 96 97 109 102]
NumBins: 10
BinEdges: [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]
BinWidth: 0.1
BinLimits: [0 1]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
So you need to do something like:
h1 = histogram(data1);
h2 = histogram(data2, h1.BinEdges); % Make sure it has the same bin edges as the first histogram.
counts1 = h1.Values;
counts2 = h2.Values;
Dist12 = sqrt(sum((counts1 - counts2) .^ 2));
or whatever you want to do or whatever formula you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by