最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【圖像增強】基于蝙蝠算法實現(xiàn)直方圖增強附matlab代碼

2022-04-04 15:20 作者:Matlab工程師  | 我要投稿

1 簡介

圖像增強是數(shù)字圖像的預(yù)處理,對圖像整體或局部特征能有效地改善.我們討論了基于蝙蝠算法優(yōu)化直方圖增強的參數(shù);同時,以一個灰度圖像為例,用MATLAB語言實現(xiàn)了蝙蝠算法優(yōu)化直方圖均衡化和規(guī)定化增強處理。

2 部分代碼

%In this code, the two controlling parameters are lamda and gamma,%increasing lamda increases contrast whereas increasing gamma,%slowly(usually between 1000-100000) retains the overbrightness of white %pixels.%in original paper, the scholar hasn't used lamda in cdf function,%hence thereby, restricting himself to increase lamda%line 53 and 54 contains lamda and gamma respectively% clcclear allfor p=1:255 ? for q=1:256 ? ? ? if p==q ? ? ? ?D(p,q) = -1; ? ? ? elseif q==p+1 ? ? ? ? ? D(p,q) = 1; ? ? ? else ? ? ? ? ? D(p,q) = 0; ? ? ? end ? end end clci = imread('ImgOrig.png');r = i(:,:,1);g = i(:,:,2);b = i(:,:,3);figure,imshow(i)title('Original Image')%for n=1:256 % ? histogram(1,n) = 0;%for l = 1:size_of_image(1) % ? for b = 1:size_of_image(2) ?% ? ? ?if grays(l,b)==n ? % ? ? histogram(1,n) = histogram(1,n)+1; ? ?% ? ?end ? ?%end%end%end%x = 1:1:256;%figure, plot(x,histogram)[freqr xr] = ?imhist(r);[freqg xg] = ?imhist(g);[freqb xb] = ?imhist(b);size_of_image = size(r);number_of_pixels = size_of_image(1)*size_of_image(2);lamda = 5;%variable to determine the amount of contrastgamma = 50000 ;% smoothing_factor = inv(((1+lamda).*eye(256) + gamma.*transpose(D)*D));% for n = 0:1:255 ? ? ? ? ? ? ? ? ? ? % ? ? nfreqr(n+1,1) = (freqr(n+1,1) + lamda*n);% ? ? nfreqg(n+1,1) = (freqg(n+1,1) + lamda*n);% ? ? nfreqb(n+1,1) = (freqb(n+1,1) + lamda*n);% end% % freqr = smoothing_factor*nfreqr;% freqg = smoothing_factor*nfreqg;% freqb = smoothing_factor*nfreqb;hir = freqr; ? ? ? ? ? ? ? ?%for R[freqr,fminr] = bat_algorithm_image(20,1000, 0.5 ,0.5,hir,lamda,gamma,D,xr);freqr = transpose(freqr);hig = freqg; ? ? ? ? ? ?%for G[freqg,fming] = bat_algorithm_image(20 ,1000, 0.5 ,0.5,hig,lamda,gamma,D,xg);freqg = transpose(freqg);hib = freqb; ? ? ? ? ? ? ? %for B[freqb,fminb] = bat_algorithm_image(20 ,1000, 0.5 ,0.5,hib,lamda,gamma,D,xb);freqb = transpose(freqb);for n = 0:1:255 ? ? ? ? ? ? ? ? ? ? %probablity Density Function ? ?p(n+1,1) = freqr(n+1,1)/number_of_pixels;endcr = zeros(256,1); %cumulative density function cg = zeros(256,1); cb = zeros(256,1); cr(1,1) = freqr(1,1);cg(1,1) = freqg(1,1); cb(1,1) = freqb(1,1);for n = 1:1:255 ? ?cr(n+1,1) = cr(n,1) + freqr(n+1,1); ? ?cg(n+1,1) = cg(n,1) + freqg(n+1,1); ? ?cb(n+1,1) = cb(n,1) + freqb(n+1,1);endfor n = 0:1:255 ? ?cr(n+1,1) = cr(n+1,1)/number_of_pixels; ? ?cg(n+1,1) = cg(n+1,1)/number_of_pixels; ? ?cb(n+1,1) = cb(n+1,1)/number_of_pixels;endcdfr = (lamda+1)*(255.*cr + 0.5);cdfg = (lamda+1)*(255.*cg + 0.5);cdfb = (lamda+1)*(255.*cb + 0.5);cdfr = round(cdfr);cdfg = round(cdfg);cdfb = round(cdfb);%main Imagemain_image = uint8(zeros(size_of_image(1),size_of_image(2),3));c = 1; ? ?for l = 1:size_of_image(1) ? ? ? ?for w = 1:size_of_image(2) ? ? ? ? ? ? main_image(l,w,c) = cdfr(r(l,w)+1,1); ? ? ? ? ? ? main_image(l,w,c+1) = cdfg(g(l,w)+1,1); ? ? ? ? ? ? main_image(l,w,c+2) = cdfb(b(l,w)+1,1); ? ? ? ?end ? ?endfigure, imshow(main_image),title('Histogram Modified')figure, hist(main_image(:,:,1),xr);hold onhist(main_image(:,:,2),xg);hist(main_image(:,:,3),xb);entropy_of_original_image = entropy(i)entropy_of_image = entropy(main_image)mean_Optimized = mean2(main_image);var_optimzed = std2(main_image);D = abs(uint8(main_image) - uint8(i)).^2;mse = sum(D(:))/numel(main_image);psnr = 10*log10(255*255/mse);%mae = meanAbsoluteError(main_image,i)%E = eme(main_image,size_of_image(1),5)

3 仿真結(jié)果


4 參考文獻

[1]汪志云, 黃夢為, 胡釙,等. 基于直方圖的圖像增強及其MATLAB實現(xiàn)[J]. 計算機工程與科學(xué), 2006(2):54-56.

博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。

部分理論引用網(wǎng)絡(luò)文獻,若有侵權(quán)聯(lián)系博主刪除。



【圖像增強】基于蝙蝠算法實現(xiàn)直方圖增強附matlab代碼的評論 (共 條)

分享到微博請遵守國家法律
陕西省| 崇信县| 永德县| 永昌县| 合山市| 哈巴河县| 深州市| SHOW| 罗田县| 富平县| 合阳县| 桃园市| 乐昌市| 兴化市| 东乡县| 敦化市| 新泰市| 建湖县| 台安县| 鞍山市| 江都市| 宣威市| 沅陵县| 田阳县| 南昌县| 库车县| 遵义市| 土默特右旗| 万宁市| 南通市| 政和县| 五台县| 神木县| 绥德县| 鹤壁市| 珲春市| 湖南省| 永善县| 石阡县| 平度市| 南雄市|