将直方图分为两个区域 [英] Split the histogram into two regions
本文介绍了将直方图分为两个区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将直方图分为两个区域(通过获取直方图图像的平均强度值).
I want to divide the histogram into two regions (by taking the avg intensity value of histogram image).
hR = imhist(redChannel);
minRed = min(redChannel(:));
maxRed = max(redChannel(:));
avgRed = (minRed+maxRed)/2;
hlowR = hR(1:avgRed);
hhighR = hR(avgRed:256);
hlowR提供值,但hhighR为空.我不知道怎么了请帮忙.谢谢
hlowR is giving the values but hhighR is empty. I don't know what's wrong. Please help. Thanks
推荐答案
hR = imhist(redChannel);
% minRed = min(redChannel(:));
% maxRed = max(redChannel(:));
% avgRed = (minRed+maxRed)/2;
avgRed = mean(redChannel(:)); % get mean directly
hlowR = hR(hR<=avgRed); % Logical index to find all values below the average
hhighR = hR(hR>=avgRed);% Logical index to find all values above the average
You are using avgRed
directly as index, whilst you should check whether a value of hR
is above or below it, using logical indexing.
这篇关于将直方图分为两个区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文