2017-11-25 1 views
1

私はmatlabで作業していますが、グレースケール画像とRGB画像のコントラストストレッチを適用したいのですが、これを試してみました。コントラストはMATLABでコラーレ画像を伸ばします

 clear all; 
     clc; 
     itemp = imread('cameraman.tif'); %read the image 
     i = itemp(:,:,1); 
     rtemp = min(i);   % find the min. value of pixels in all the 
     columns (row vector) 
     rmin = min(rtemp);  % find the min. value of pixel in the image 
     rtemp = max(i);   % find the max. value of pixels in all the 
     columns (row vector) 
     rmax = max(rtemp);  % find the max. value of pixel in the image 
     m = 255/(rmax - rmin); % find the slope of line joining point 
     (0,255) to (rmin,rmax) 
     c = 255 - m*rmax;  % find the intercept of the straight line 
     with the axis 
     i_new = m*i + c;  % transform the image according to new slope 
     figure,imshow(i);  % display original image 
     figure,imshow(i_new); % display transformed image 

これは、グレースケール画像のために、

問題は、私はRGBの画像 のための任意のアイデアを行う方法がわからないということですか?それを実装する方法は? はあなたに感謝:)

答えて

1

機能stretchlimreference)はあなたの目的に役立つでしょうか?

ストレッチ画像のコントラストを制限します。

Low_High = stretchlim(RGB、公差)がLow_High、トゥルーカラーイメージRGB延伸コントラスト 使用することができる下限と上限を指定するピクセル値の2要素ベクトル を返します。

img = imread('myimg.png'); 
lohi = stretchlim(img,[0.2 0.8]); 
0

あなたは

rmin = min(i(:)); 

を記述する場合、それはi内のすべての値に対して最小値を計算します。これは、3次元に沿った3つの値を持つ3DマトリックスであるRGBイメージにも有効です。

残りのコードは、そのような画像にも直接適用されます。

関連する問題