PS 滤镜— —挤压效果
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 滤镜— —挤压效果的更多相关文章
- Python: PS 滤镜--万花筒效果
本文用 Python 实现 PS 的一种滤镜效果,称为万花筒.也是对图像做各种扭曲变换,最后图像呈现的效果就像从万花筒中看到的一样: 图像的效果可以参考之前的博客: http://blog.csdn. ...
- PS 滤镜— —Marble 效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- PS 滤镜— — 万花筒效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- PS 滤镜— —水波效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- PS 滤镜— — sparkle 效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- PS 滤镜— —球面化效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- PS滤镜— —波浪效果
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- OpenCV——PS滤镜 水波效果
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- Python: PS 滤镜--旋涡特效
本文用Python 实现 PS 滤镜的旋涡特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/42215 ...
随机推荐
- iOS base64加密解密
本文转载至 http://jingyan.baidu.com/article/93f9803fff45c9e0e46f5596.html 从参考资料的地址中下载GTMBase64.zip库文件包,并解 ...
- intellij idea pycharm phpstorm webstorm 使用 FiraCode 作为编程字体,更新后字符乱码问题解决
先说使用下载 传送门 https://pan.baidu.com/s/1OI-novVYy-C74HIUfr9E6w windows: 1.下载后打开ttf文件夹,选择所有右键安装. 2.或者使用ch ...
- Hadoop DataNode 节点的动态添加和动态删除
动态添加 DataNode 节点 hadoop环境是必须的 需要加入新的 DataNode 节点,前提是已经配置好 SSH 无密登录:直接复制已有DataNode中.ssh目录中的authorized ...
- 【HTML5开发系列】CSS3
选择器 属性 背景和边框 盒模型 布局 文本 动画 其他
- Ubuntu中安装FTP 服务器自己踩得坑
12点多了,擦!做个码农真不容易呀! 系统:Ubuntu16.04 安装:FTP 步骤: 1.不管有没有一上来我先卸载: sudo apt-get purge vsftpd 2.再安装:sudo ap ...
- mysql mariadb 乱码
mysql 创建临时表 CREATE TEMPORARY TABLE tmp_table SELECT COUNT(*) AS num FROM student_info GROUP BY LEFT( ...
- mac上傻瓜式java安装环境配置
适用于mac新手用户或者黑苹果用户 首先,打开终端 输入 java -version 检查是否已安装好Java运行环境 显示我现在电脑没有安装 如果返回版本号,说明运行环境成功 对于windows用过 ...
- LeetCode:完全平方数【279】【DP】
LeetCode:完全平方数[279][DP] 题目描述 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n.你需要让组成和的完全平方数的个数最少. 示 ...
- Kattis - entertainmentbox 【贪心】
思路 先将 N 个 电视节目 排序 根据 结束时间 ,结束的早的 排在前面 然后 弄 K个标记 记录 结束时间 然后 遍历一下 每次 如果能插入的话 插入到 结束时间最小的那个 队列里面去然后 每次插 ...
- linux中什么是文件结构体?
struct file结构体定义在include/linux/fs.h中定义.文件结构体代表一个打开的文件,系统中的每个打开的文件在内核空间都有一个关联的 struct file.它由内核在打开文件时 ...