直方图划分和拉伸[关闭]

问题描述 投票:0回答:1

我想通过将直方图划分为两个区域(通过获取直方图图像的平均强度值)并在两个区域上执行直方图拉伸来在增强和过度增强的图像下创建。

    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);

现在,我如何伸展hlowRhhighR

matlab
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.