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!