clc;
clear all;
close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread('4.jpg');
I=double(I);
Image=I/255; angle = pi/4;
centreX = 0.5;
centreY = 0.5;
radius=200;
amount=0.75; [height, width, depth]=size(Image); Image_new=Image; icentreX = width * centreX;
icentreY = height * centreY; if ( radius == 0 )
radius=min(icentreX, icentreY);
end radius2=radius*radius; for ii=1:height for jj=1:width dx = jj-icentreX;
dy = ii-icentreY; distance = dx*dx + dy*dy; if (distance>radius2 || distance==0)
x=jj;
y=ii;
else
d = sqrt( distance / radius2 );
t = sin( pi*0.5 * d ).^(-amount); dx =dx* t;
dy =dy* t; e = 1 - d;
a = angle * e * e; s = sin( a );
c = cos( a ); x = icentreX + c*dx - s*dy;
y = icentreY + s*dx + c*dy;
end if (x<=1) x=1; end
if (x>=width) x=width-1; end;
if (y>=height) y=height-1; end;
if (y<1) y=1; end; % % if (x<=1) continue; end
% % if (x>=width) continue; end;
% % if (y>=height) continue; end;
% % if (y<1) continue; end; x1=floor(x);
y1=floor(y);
p=x-x1;
q=y-y1; Image_new(ii,jj,:)=(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 滤镜— —Marble 效果

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

  3. PS 滤镜— — 万花筒效果

    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. jvm 调优参数

    -server -Xms6000M -Xmx6000M -Xmn500M -XX:PermSize=500M -XX:MaxPermSize=500M -XX:SurvivorRatio=65536 ...

  2. visual studio code (vscode)像 sublime text 的 ctrl+d 一样多光标选中

    快捷键是 ctrl+m ,返回上一个选中时ctrl+u. 文件 ==>首选项 ==>键盘快捷键() 里面可以查到,下一个是“将选择添加到下一个查找匹配项”,返回上一个是“cursorund ...

  3. spring boot mysql和mybatis

    1 选择mysql驱动 <dependency> <groupId>mysql</groupId> <artifactId>mysql-connecto ...

  4. On the importance of initialization and momentum in deep learning

    Ilya Sutskever1 ilyasu@google.com James Martens jmartens@cs.toronto.edu George Dahl gdahl@cs.toronto ...

  5. windows下php升级到7.2

    1: 官网下载:https://windows.php.net/download#php-7.2

  6. ob 函数讲解

    ob的基本原则:如果ob缓存打开,则echo的数据首先放在ob缓存.如果是header信息,直接放在程序缓存.当页面履行到最后,会把ob缓存的数据放到程序缓存,然后依次返回给涉猎器.下面我说说ob的基 ...

  7. spring+hibernate+springmvc整合框架搭建

    搭建maven web项目这里不再讲述,详情请查看http://www.cnblogs.com/wql025/p/5215570.html 现在讲述项目的搭建过程. 1.通过maven导入项目所用的j ...

  8. python元组和列表区别

    元组可以简单认为是一个只读的列表 tuper = const list

  9. Qt Creator 调试器 在 Ubuntu 13.10下 局部变量和表达式(Locals) 无内容

    此篇算是一个翻译,万一有国内同样的小白遇到同样问题,方便参考. 原文http://hostilefork.com/2013/10/20/qtcreator-debugger-no-locals-ubu ...

  10. Linux:进程管理

    Linux:进程管理 进程间通信 文件和记录锁定. 为避免两个进程间同时要求访问同一共享资源而引起访问和操作的混乱,在进程对共享资源进行访问前必须对其进行锁定,该进程访问完后再释放.这是UNIX为共享 ...