2017-01-10 6 views
0

ヒストグラムを2つの領域に分割し(ヒストグラム画像の平均輝度値を取ることによって)、両方の領域でヒストグラムストレッチを実行することで、強調表示と強調表示の両方で画像を作成したいと考えています。どうすればいいのか教えてください。おかげヒストグラム分割とストレッチ

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の両方をストレッチします。どうすればいいのか教えてください。

+0

このコードは、あなたの[元の質問]によって明らかなように、動作しません(http://stackoverflow.com/ q/41546973/5211833)。また、私は[私のコメント](http://stackoverflow.com/questions/41546973/split-the-histogram-into-two-regions/41547609?noredirect=1)にあなたに尋ねたように、何も試してみませんでしたか? #comment70336374_41547609)、ヘルプセンターの[質問]ページを引用していますか? – Adriaan

答えて

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) 
関連する問題