A list,

Image quality improvement based on Matlab Laplace filter

Ii. Source code

unction HighBoostFiltering 

handle=figure;
set(handle,'unit'.'pixels'.'position'[0 0 1000 600]);
movegui(handle, 'center' );

img=imread('k.bmp'); [h w]=size(img); filter_mask={... Define two Laplace filters [0 - 1 0;- 1 4 - 1;0 - 1 0]; . % Ordinary Laplace filter [- 1 - 1 - 1; - 1 8 - 1 ;- 1 - 1 - 1]}; % extended Laplace filter A=1.7; Imgsharp2 =imfilter(double(img),...
        filter_mask{1},...          
        'corr'.'symmetric'.'same'); % imfilter function: returns the same processing image type as the input image; Corr is correlation, because the Laplace operator is centrosymmetric, so convolution is the same as correlation; Symmetric is mirror replication. Same is the same size. imgafter2=double(img).*A+imgsharp2; imgafter2=uint8(imgafter2); % uint8 Cast: If the input data isdouble, the data is rounded to less than0The place for0. subplot(241),imshow(img),                   title('This behavior is implemented by Matla's IMfilter');
subplot(242),imshow(uint8(imgsharp2)),      title('Uncalibrated Laplace filter');
subplot(243),imshow(mat2gray(imgsharp2)),   title('Calibrated Laplace filter');
subplot(244),imshow(imgafter2),             title('Final diagram'); %% write algorithm m=1; n=1;    
imgMSR=EdgeFilling(img,m,n,1); % the edges of the image fill the pixels of the mirror, because the Laplace operator is3*3, so horizontal and vertical fill a pixel unit imgMSR=double(imgMSR); % expanded image conversiondoubleType imgsharp1 = imgMSR; The % Laplace operator is zero3*3Hwait =waitbar(hwait=waitbar(0.'Please wait >>>>>>>>');
for i=1+m:h+m
    for j=1+n:w+n
        [p,q,r,t]=safeborder(h+2*m,w+2*n,i,j,m,n);
        tempimg=imgMSR(p:q,r:t);
        imgsharp1(i,j)=sum(sum(tempimg.*filter_mask{1}));
    end
    if i/h>0.8
        set(findobj(hwait,'type'.'patch'),'edgecolor'.'g'.'facecolor'.'g');
    end
    waitbar(i/h,hwait,'In process');
end
imgsharp1=imgsharp1(1+m:h+m,1+n:w+n); Imgafter1 = take the middle part and remove the borderdouble(img).*A+imgsharp1;
imgafter1=uint8(imgafter1);
close(hwait);
subplot(245),imshow(img),                   title('This behavior is handled by the code I wrote.');
subplot(246),imshow(uint8(imgsharp1)),      title('Uncalibrated Laplace filter');
subplot(247),imshow(mat2gray(imgsharp1)),   title('Calibrated Laplace filter');
subplot(248),imshow(imgafter1),             title('Final diagram'); Finally, it is found that high-lift filtering not only improves details, but also improves brightness, depending on the value of A. Function imgMSR=EdgeFilling(img,m,n,which) % for image EdgeFilling, % filling schemes include: % mirror copy which=1Fill with black which=2Fill with grey which=3Fill with white which=4

[h w]=size(img);
if which==1
    fill=img;
elseif which==2
    fill=uint8(zeros(h,w));
elseif which==3
    fill=uint8(ones(h,w)*127);
elseif which==4
    fill=uint8(ones(h,w)*255);
end
Copy the code

3. Operation results

Fourth, note

Version: 2014 a

Complete code or ghostwrite plus 1564658423