MATLAB exercise program (Radial fuzzy 1)

Source: Internet
Author: User

The reason why I want to add 1 is that this is not done yet. It is implemented according to my own ideas and the result is... No.

I am not clear about the radial Fuzzy Algorithm in Photoshop, but the following dialog box can be roughly guessed:

Just look at the small box. I feel that Photoshop is only blurred in the place corresponding to the black pixel, but not in other places. For the moment, I only achieve the scaling effect. It is still unclear how to change the quality.

My algorithm is to calculate the convolution template for each pixel separately. The convolution template is determined by the convolution radius R and the slope of the current pixel and the image center pixel.

The following code is used:

Main. m

Clear all; close all1_clc1_r1_301_img1_imread('lena.jpg '); [m n] = size (IMG); imshow (IMG) imgn = zeros (m + 2 * r + 1, n + 2 * r + 1); imgn (R + 1: m + R, R + 1: N + R) = IMG; imgn (1: R, R + 1: N + R) = IMG (1: R, 1: N); % extended upper boundary imgn (1: m + R, N + R + 1: n + 2 * r + 1) = imgn (1: m + R, N: N + r); % extend the right boundary imgn (m + R + 1: m + 2 * r + 1, R + 1: n + 2 * r + 1) = imgn (M: m + R, R + 1: n + 2 * r + 1); % extended lower boundary imgn (1: m + 2 * r +: R) = imgn (1: m + 2 * r + 1, R + * r); % expanded left boundary cen_y = floor (M/2 + r); cen_x = floor (n/2 + r); for I = R + 1: m + R for J = R + 1: N + r w = create_mk (I, j, cen_y, cen_x, R ); % manufacturing convolution template [H w] = size (w); HH = floor (H/2); ww = floor (W/2); s = imgn (I-hh: I + HH, J-ww: J + ww ). * w; imgn (I, j) = sum (s)/sum (w); End endimgn = imgn (R + 1: m + R, R + 1: N + r); figure; imshow (mat2gray (imgn ));

Create_mk.m

Function W = create_mk (I, j, cen_y, cen_x, R) If J ~ = Cen_x k = (i-cen_y)/(j-cen_x); Theta = atan (k); jiaodu = Theta * 180/PI; % don't radian is know Tan (PI/2) how many else jiaodu = 90; end jiaodu = Mod (jiaodu, 360); flag = 0; % The following shows the width and height of the convolution template. If jiaodu> = 0 & jiaodu <90% jiaodu = jiaodu; flag = 1; end if jiaodu> = 90 & jiaodu <180 jiaodu = 180-jiaodu; flag = 2; end if jiaodu> = 180 & jiaodu <270 jiaodu = jiaodu-180; flag = 3; end if jiaodu> = 270 & jiaodu <360 jiaodu = 360-jiaodu; flag = 4; end H = floor (R * sin (jiaodu * PI/180); W = floor (R * Cos (jiaodu * PI/180); If Mod (H, 2) = 0 h = H + 1; end if Mod (W, 2) = 0 w = W + 1; end W = zeros (H, W ); % is the convolution template value: pre_tmp_y = 1; pre_tmp_x = 1; if W ~ = 1 & H ~ = 1 for I = 1: H for j = 1: W tmp_y = floor (J * Tan (jiaodu * PI/180); If tmp_y = I w (pre_tmp_y: tmp_y, j) = r; W (pre_tmp_y, pre_tmp_x: J) = r; pre_tmp_y = tmp_y; pre_tmp_x = J; end W (H, W) = R; end if W = 1 for I = 1: h w (I, 1) = r; end if H = 1 for j = 1: w (1, J) = r; end W = W/sum (w); If flag = 2 | flag = 4% if the angle is in the quadrants of 2 and 4, convolution matrix up/down flip W = flipud (w); end

Effect:

Source image

The effect here, with a radius of 30

The number of Photoshop files is 61.

When I saw these two figures, I suddenly understood the differences between diaosi and Bai fumei, and between domestic and foreign smart machines. In short, the effect gap is still very large. In fact, the speed gap is also very large, and the algorithm needs to be optimized. It is recorded here temporarily.

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.