Histeq Syntax J = histeq ( I , hgram ) J = histeq ( I , n ) [ J , T ] = histeq ( I , … ) Newmap = histeq ( X , map , hgram ) Newmap = histeq ( X , map ) [ newmap , T ] = histeq ( X , … ) Img 4 = histeq ( img 1 )
I = imread ( ‘tire . tif ‘ ) ; J = histeq ( I ) ; Imshow ( I ); Figure , imshow ( J )
%% Load Image Mu = 180 ; Sigma = 30 ; H=@(X) exp(-1/(2*sigma^2)*(x-mu).^2; X=0:255; Hgram=H(x); stem(x,hgram); npixel=numel(img1); >>size(img1) Ans= 291 240 >>291*240 Ans= 69840 >>prod(size)) Ans= 69840
>>numel(img1) Ans = 69840
Hgram= Hgram/sum(hgram); >>sum(hgram) Ans= 1.000 >>hgram=npixel*hgram/sun(hgram);
>>sum(hgram) Ans= 6.9840e+04
>>sum(hgram) Ans= 69832 >>npixel Npixel= 69840
Img2=histeq(img1,hgram); % show Results Figure ; Subplot ( 2 , 2 , 1 ) ; imshow ( img 1 ) ; title ( ‘ original Image ‘ ) ; subplot ( 2 , 2 , 2 ) ; imshow ( img 2 ) ; title ( ‘ Result of histeq ‘ ) ; subplot ( 2 , 2 , 3 ) ; imhist ( img 1 ) ; subplot ( 2 , 2 , 4 ) ; imhist ( img 2 ) ;
Img 1 imread ( ‘ pout . tif ‘ ) ; Npixel 1 = nume 1 ( img 1 ) ; W 1 = 5 ; Mu 1 = 50 ; Sigma 1 = 30 ; W2 = 10 ; Mu 2 =180 ; Sigma 2 = 50 ; H = @ ( X ) w 1 * exp ( -1 / ( 2 * sigma 1 ^ 2 ) * ( x – mu 1 ) . ^ 2 ) +w 2 * exp ( -1 / (2 * sigma 2 ^ 2 ) * (x – mu 2 ) . ^ 2 ) ; X = 0 : 255 ; Hgram = H ( x ) ; Hgram = round ( npixe 1 * hgram / sum ( hgram ) ) ; Img 2 = histeq ( img , hgram ) ;
%%Load Image Img1 = imread ( ‘pout . tif ‘ ) ; Img2 = adapthisteq (img 1) ; %% Show Results Figure ; Subplot ( 2 , 2 , 1 ); Imshow (img 1) ; Title ( ‘ Original Image ‘) ; Subplot ( 2 , 2 , 2); Imshow (img2) ; Title ( ‘Result of adapthisteq ‘ );
ادامه آموزش در مبحث 5