我想通过将直方图划分为两个区域(通过获取直方图图像的平均强度值)并在两个区域上执行直方图拉伸来创建增强和过度增强图像。
rgbImage=imread('2.jpg');
redChannel = rgbImage(:, :, 1);
hR = imhist(redChannel);
minRed = min(redChannel(:));
maxRed = max(redChannel(:));
avgRed = (minRed+maxRed)/2;
hlowR = hR(1:avgRed);
hhighR = hR(avgRed:255);
现在,我如何延伸hlowR
和hhighR
?
答案 0 :(得分:1)
如果我理解你的问题,这里有一个代码可以解决你的问题:
%open the image
rgbImage=imread('image.jpg');
redChannel = rgbImage(:, :, 1);
%calculate the median
minRed = min(redChannel(:));
maxRed = max(redChannel(:));
MedRed = (minRed+maxRed)/2;
%Histogram equalization on the first part of the histogram.
hlowR = redChannel;
hlowR(~ismember(redChannel,0:MedRed )) = 0;
hlowR = double(hlowR);
hlowR = uint8(((hlowR-min(hlowR(:)))./(max(hlowR(:))-min(hlowR(:))))*255);
%Histogram equalization on the second half part of the histogram.
hhighR = redChannel;
hhighR(~ismember(redChannel,MedRed :255)) = MedRed ;
hhighR = double(hhighR);
hhighR = uint8(((hhighR-min(hhighR(:)))./(max(hhighR(:))-min(hhighR(:))))*255);
%display the result
imagesc(hhighR)
figure
imagesc(hlowR)