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 ...
随机推荐
- CentOS 7.x samba 服务器安装
以下以root用户执行 1.安装: # yum install samba samba-client -y 2.设置开机启动: # systemctl enable smb.service ln ...
- CAFFE学习笔记(一)Caffe_Example之训练mnist
0.参考文献 [1]caffe官网<Training LeNet on MNIST with Caffe>; [2]薛开宇<读书笔记4学习搭建自己的网络MNIST在caffe上进行训 ...
- 九度OJ 1326:Waiting in Line(排队) (模拟)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:220 解决:64 题目描述: Suppose a bank has N windows open for service. There is ...
- HTML-Table-Td固定宽度使内容换行
table style="TABLE-LAYOUT: fixed;" td style="WORD-WRAP: break-word;WIDTH:200px;"
- PAT 1055. 集体照 (25)
拍集体照时队形很重要,这里对给定的N个人K排的队形设计排队规则如下: 每排人数为N/K(向下取整),多出来的人全部站在最后一排: 后排所有人的个子都不比前排任何人矮: 每排中最高者站中间(中间位置为m ...
- js判断undefined类型,undefined,null, 的区别详细解析
js判断undefined类型 今天使用showModalDialog打开页面,返回值时.当打开的页面点击关闭按钮或直接点浏览器上的关闭则返回值是undefined所以自作聪明判断 var reVal ...
- ZOJ - 3705 Applications 【模拟】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3705 题意 给出N个队员 然后一个教练要从中选择 M名队员 要选 ...
- Spring MVC 通过反射将数据导出到excel
直接上代码 // 导出excel方法 @RequestMapping("exportExcel") public void exportExcel(HttpServletReque ...
- selenium主要功能封装
最近实习需要使用selenium这一自动化工具对公司的运维监控系统进行自动化爬取数据,编写代码过程中负责带我的杰哥让我参考借鉴他们公司外包的运维监控系统代码,在项目中我看到了对selenium主要各功 ...
- 【Flask】下载多个文件
使用zipfile模块可以将多个文件打包成zip文件进行下载,但是常规的操作方式会在服务器磁盘上生成一个zip文件占用磁盘空间. 后引入BytesIO将文件写入到内存中然后下载: def dl_pla ...