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 ...
随机推荐
- unity 常用的几种相机跟随
固定相机跟随 这种相机有一个参考对象,它会保持与该参考对象固定的位置,跟随改参考对象发生移动 using UnityEngine; using System.Collections; public c ...
- 附004.Kubernetes Dashboard简介及使用
一 Kubernetes dashboard简介 1.1 Web UI简介 dashboard是基于Web的Kubernetes用户界面.可以使用dashboard将容器化应用程序部署到Kuberne ...
- spring配置加载2次实例问题。
WEB.XML 中SPRING 配置及重复加载问题 Posted on 2012-11-13, 15:48, by tmser, under java 周边 . 项目内存溢出,mat 查看了一下发现s ...
- xCode9 一直Indexing
解决办法:打开终端输入:defaults write com.apple.dt.XCode IDEIndexDisable 1 然后重新打开工程就可以了
- spring 注入属性
一.注入对象类型的数据 1.配置文件 User类与UserService类均需要创建对象.所以都配置其相应的bean类,另外user需作为userService的属性注入,所以userService需 ...
- jQuery实现复选框全选/所有取消/反选/获得选择的值
<!DOCTYPE html> <html> <head> <script type="text/javascript" src=&quo ...
- LeetCode:寻找重复数【287】
LeetCode:寻找重复数[287] 题目描述 给定一个包含 n + 1 个整数的数组 nums,其数字都在 1 到 n 之间(包括 1 和 n),可知至少存在一个重复的整数.假设只有一个重复的整数 ...
- 每天一个Linux命令(15)tail命令
tail命令用于输入文件中的尾部内容.tail命令默认在屏幕上显示指定文件的末尾10行. 如果给定的文件不止一个,则在显示的每个文件前面加一个文件名标题. (1)用法: 用法: tail ...
- composer 更新国内镜像地址
composer config -g repo.packagist composer https://packagist.phpcomposer.com
- C语言伪随机数的注意事项
不要将srand(time(NULL))或srand(time(0))放到循环中,因为我们两次调用srand()函数设置随机数种子之间的时间间隔不超过1s,等价于使用了一个固定的随机数种子,会出现相同 ...