Second, Photoshop image Filter--Sketch algorithm
Sketch algorithm, there are many network, but the effect is not particularly ideal. Friends who are familiar with Photoshop know that the effect of drawing color pictures is only a few steps: 1, de-color, 2, copy the color layer, and inverse color, 3, the inverse color image gaussian blur, 4, the blurred image overlay mode to select the color Dodge effect.
The color of the image is relatively simple, not much to explain. Assuming that the original image is X, the processed image is Y, that is, for coordinates (I,J), the inverse color is y (i,j) =255-x (i,j). Gaussian Blur is quite similar to a low-pass filter, and friends can find information about Gaussian blur. The color Dodge algorithm is this: C =min (A + (AXB)/(255-b), 255), where c is the mixed result, a is the source pixel, and B is the target pixel point.
The MATLAB code is as follows:
I=imread (' a1.jpg ', ' jpg ');
Imshow (I);
Figure ();
Info_size=size (I);
Height=info_size (1);
Width=info_size (2);
N=zeros (height,width);
G=zeros (height,width);
Imggray=rgb2gray (I);
Out=zeros (height,width);
Spec=zeros (height,width,3);
For i=1:height for
j=1:width
N (i,j) =255-imggray (i,j);
End
End for
i=2:height-1 for
j=2:width-1
sum=0;
Sum=1*double (n (i-1,j-1)) +2*double (n (i-1,j)) +1*double (n (i-1,j+1));
Sum=sum+2*double (n (i,j-1)) +4*double (n (i,j)) +2*double (n (i,j+1));
Sum=sum+1*double (n (i+1,j-1)) +2*double (n (i+1,j)) +1*double (n (i+1,j+1));
SUM=SUM/16;
G (I,j) =sum;
End
End for
i=1:height for
j=1:width
b=double (g (i,j));
A=double (Imggray (i,j));
temp=a+a*b/(256-b);
Out (i,j) =uint8 (min (temp,255));
End
End
imshow (out/255);
After processing the image is as follows:
Welcome friends more advice, welcome to share, please specify the source-----(WSFDL)!