PS filter-radial blur

Source: Internet
Author: User

Here we provide a fuzzy algorithm for grayscale images. Color images only need to blur three channels.


% Radiation blur
%

Clc;
Clear all;
Close all;

I =imread('4.jpg ');
I = double (I );
% Image = I;

Image = 0.2989 * I (:,:, 1) + 0.5870 * I (:,:, 2) + 0.1140 * I (:,:, 3 );


[Row, col] = size (Image );
Image_new (1: row, 1: col) = 255;
Center_X = (col + 1)/2;
Center_Y = (row + 1)/2;
Alpha = 0.85;

For I = 1: floor (Center_Y)
For j = floor (Center_X) + 1: col
        
% First Quadrant
X1 = j-Center_X;
Y1 = Center_Y-i;
T1 = Image (I, j );
        
% Third quadrant
X3 =-x1;
Y3 =-y1;
X_image = floor (Center_X + x3 );
Y_image = floor (Center_Y-y3 );
I3 = y_image;
J3 = x_image;
T3 = Image (y_image, x_image );
        
% Second quadrant
X2 =-x1;
Y2 = y1;
X_image = floor (Center_X + x2 );
Y_image = floor (Center_Y-y2 );
I2 = y_image;
J2 = x_image;
T2 = Image (y_image, x_image );
        
% Quadrant
X4 = x1;
Y4 =-y1;
X_image = floor (Center_X + x4 );
Y_image = floor (Center_Y-y4 );
I4 = y_image;
J4 = x_image;
T4 = Image (y_image, x_image );
        
K = y1/x1;
X_start = x1 * alpha;
Y_start = k * x_start;
X_end = x1;
Y_end = y1;
X = x_start;
Y = y_start;
        
If (x1> y1)
Num_Pixel = floor (x_end-x_start) + 1;
For x = x_start: x_end-1
Y0 = k * (x + 1 );
% First Quadrant
X1 = x + 1;
Y1 = round (y0 );
% Y = y + 1;
X_image = floor (Center_X + x1 );
Y_image = floor (Center_Y-y1 );
T1 = T1 + Image (y_image, x_image );
                  
% Third quadrant
X3 =-x1;
Y3 =-y1;
X_image = floor (Center_X + x3 );
Y_image = floor (Center_Y-y3 );
T3 = T3 + Image (y_image, x_image );
                    
% Second quadrant
X2 =-x1;
Y2 = y1;
X_image = floor (Center_X + x2 );
Y_image = floor (Center_Y-y2 );
T2 = T2 + Image (y_image, x_image );
                    
% Quadrant
X4 = x1;
Y4 =-y1;
X_image = floor (Center_X + x4 );
Y_image = floor (Center_Y-y4 );
T4 = T4 + Image (y_image, x_image );
End
Else
Num_Pixel = floor (y_end-y_start) + 1;
For y = y_start: y_end-1
X0 = (y + 1)/k;
% First Quadrant
X1 = floor (x0 );
Y1 = y + 1;
X_image = floor (Center_X + x1 );
Y_image = floor (Center_Y-y1 );
T1 = T1 + Image (y_image, x_image );
                  
% Third quadrant
X3 =-x1;
Y3 =-y1;
X_image = floor (Center_X + x3 );
Y_image = floor (Center_Y-y3 );
T3 = T3 + Image (y_image, x_image );
                    
% Second quadrant
X2 =-x1;
Y2 = y1;
X_image = floor (Center_X + x2 );
Y_image = floor (Center_Y-y2 );
T2 = T2 + Image (y_image, x_image );
                    
% Quadrant
X4 = x1;
Y4 =-y1;
X_image = floor (Center_X + x4 );
Y_image = floor (Center_Y-y4 );
T4 = T4 + Image (y_image, x_image );
End
End
Image_new (I, j) = T1/Num_Pixel;
Image_new (i2, j2) = T2/Num_Pixel;
Image_new (i3, j3) = T3/Num_Pixel;
Image_new (i4, j4) = T4/Num_Pixel;
End
End

Imshow (Image_new/255 );

SOURCE image


 


 


PS filter-radial blur

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.