How can we plot pixel difference histogram accurately?
3 ビュー (過去 30 日間)
古いコメントを表示
function PDH(img1,img2)
diffImage2 = imfilter(img2, [1, -1]);
diffImage1 = imfilter(img1, [1, -1]);
minValue1 = min(diffImage1(:));
maxValue1 = max(diffImage1(:));
minValue2 = min(diffImage2(:));
maxValue2 = max(diffImage2(:));
[counts2,edge2] = histcounts(diffImage2(:));
[counts1,edge1] = histcounts(diffImage1(:));
end
problem occures when trying plotting edge against counts cause size of edges always exceeds counts by one. However,
edges1 = linspace(minValue1, maxValue1, numel(counts1)) &
edges2 = linspace(minValue2, maxValue2, numel(counts2)) solve the problrm but the shape is not clear unless achieving decimation by certain number e.g 10.
plot(edges1, counts1, edges2, counts2); % Overlapped
plot(edges1(1:10:end), counts1(1:10:end), edges2(1:10:end), counts2(1:10:end));% looks better
Is there more accurate procedure to automatically fit the gragh with proper edges scaling.
Regards
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 3 月 8 日
problem occures when trying plotting edge against counts cause size of edges always exceeds counts by one.
So plot(edge2(1:end-1), counts2) and the problem is solved.
Or use histc(), in which case the last bin will exist and will count only the values that exactly equal the upper bound of the edges.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!