clc;
clear all;
close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread('4.jpg');
I=double(I);
Image=I/255; sz=size(Image); % set the parameters
radius = 150;
angle = pi/4;
angle2=pi/4;
sides=10;
centerX = 0.5; % set the center of the circle, proportion of the image size
centerY = 0.5; iWidth=sz(2);
iHeight=sz(1); icenterX=iWidth*centerX;
icenterY=iHeight*centerY; Image_new=Image; for i=1:sz(1)
for j=1:sz(2) dx=j-icenterX;
dy=i-icenterY; r=sqrt(dy*dy+dx*dx);
theta=atan2(dy, dx)-angle-angle2; temp_theta=theta/pi*sides*0.5 ;
theta=triangle(temp_theta); if (radius)
c=cos(theta);
radius_c=radius/c;
r=radius_c * triangle(r/radius_c);
end theta=theta+angle; x=r * cos(theta)+icenterX;
y=r * sin(theta)+icenterY; if (x<=1) x=1; end
if (x>=sz(2)) x=sz(2)-1; end;
if (y>=sz(1)) y=sz(1)-1; end;
if (y<1) y=1; end; % % % if (x<=1) continue; end
% % % if (x>=sz(2)) continue; end;
% % % if (y>=sz(1)) continue; end;
% % % if (y<1) continue; end; x1=floor(x);
y1=floor(y);
p=x-x1;
q=y-y1; Image_new(i,j,:)=(1-p)*(1-q)*Image(y1,x1,:)+p*(1-q)*Image(y1,x1+1,:)...
+q*(1-p)*Image(y1+1,x1,:)+p*q*Image(y1+1,x1+1,:); end
end imshow(Image_new)
imwrite(Image_new, 'out.jpg');

参考来源:http://www.jhlabs.com/index.html

原图:

效果图:

PS 滤镜— — 万花筒效果的更多相关文章

  1. Python: PS 滤镜--万花筒效果

    本文用 Python 实现 PS 的一种滤镜效果,称为万花筒.也是对图像做各种扭曲变换,最后图像呈现的效果就像从万花筒中看到的一样: 图像的效果可以参考之前的博客: http://blog.csdn. ...

  2. PS 滤镜— —挤压效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  3. PS 滤镜— —Marble 效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  4. PS 滤镜— —水波效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  5. PS 滤镜— — sparkle 效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  6. PS 滤镜— —球面化效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  7. PS滤镜— —波浪效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  8. OpenCV——PS滤镜 水波效果

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  9. Python: PS 滤镜--旋涡特效

    本文用Python 实现 PS 滤镜的旋涡特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/42215 ...

随机推荐

  1. 实用国际(XX)计量单位表

    很多实用附录简表:http://www.zdic.net/appendix/f1.htm 计量单位简表 时间的单位换算 : 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)  1秒=1,00 ...

  2. Kindeditor上传图片回显不出来

    原因之一: 图片成功上传但是回显不出来,这个时候,要检查返回的图片地址是否加了http://这个玩意,不然会将原来的头加上图片返回地址.

  3. UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position xxx ordinal not in range(12

    python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't deco ...

  4. SQL中的四种连接方式

    转自:http://www.cnblogs.com/afirefly/archive/2010/10/08/1845906.html 联接条件可在FROM或WHERE子句中指定,建议在FROM子句中指 ...

  5. mac上完整卸载删除.简单粗暴无脑:androidstudio删除方案

    如果你是mac  ,你删除as ,删不干净也正常,你会发现安装的时候,前面的东西也在.配置文件在,会导致你以前的错误不想要的东西都在. 废话不多说,复制粘贴就是干!!!!~~~~~~~~ 第一步: 复 ...

  6. Failed to load http://wantTOgo.com/get_sts_token/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fromHere.com' is therefore not allowed access.

    Failed to load http://wantTOgo.com/get_sts_token/: No 'Access-Control-Allow-Origin' header is presen ...

  7. Python爬虫--Urllib库

    Urllib库 Urllib是python内置的HTTP请求库,包括以下模块:urllib.request (请求模块).urllib.error( 异常处理模块).urllib.parse (url ...

  8. BZOJ1815: [Shoi2006]color 有色图

    BZOJ1815: [Shoi2006]color 有色图 Description Input 输入三个整数N,M,P 1< = N <= 53 1< = M < = 1000 ...

  9. Dijkstra的堆优化

    先附上一个例题:P3371 [模板]单源最短路径 一眼扫去,最短路... spfa可行,但是今天的主题是Dijkstra: #include<iostream> #include<a ...

  10. 【JAVA学习】struts2的action中使用session的方法

    尊重版权:http://hi.baidu.com/dillisbest/item/0bdc35c0b477b853ad00efac 在Struts2里,假设须要在Action中使用session.能够 ...