How can we plot pixel difference histogram accurately?
1 次查看(过去 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!