PS 滤镜— —扇形warp
2024-10-19 16:42:44
clc;
clear all;
close all;
addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm');
I=imread('4.jpg');
I=double(I);
Image=I/255;
[height, width, depth]=size(Image);
% set the parameters
radius = 150; % control the radius of the inner circle
high = 200; % control the distance between the inner circle and outer circle
angle = 0;
spreadAngle=pi;
centerX = 0.5; % set the center of the circle, proportion of the image size
centerY = 1.0;
icenterX=width*centerX;
icenterY=height*centerY;
Image_new=Image*0;
for i=1:height
for j=1:width
dx=j-icenterX;
dy=i-icenterY;
theta=atan2(-dy, -dx)+angle;
r=sqrt(dy*dy+dx*dx);
theta=mod(theta, 2*pi);
x=width * theta/(spreadAngle+0.00001);
y=height * (1-(r-radius)/(high+0.00001));
% % 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(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
原图
效果图
最新文章
- Zabbix监控nginx-rtmp status(json版)
- redhat自定义安装必选
- IndexedDB参考资料网址
- fallacies of distributed computing
- C#设计模式(9)——装饰者模式(Decorator Pattern)
- nyoj 68 三点顺序
- 有关ZxMiddleTier构想
- c/c++编译原理
- AppiumLibrary实用函数介绍
- javamail发送邮件(转)
- java整合flex
- openstack临时存储后端
- POJ 2255 Tree Recovery 二叉树恢复
- WPF 实现验证码功能
- ①【javascript设计到的技术点】
- Kali无法启动、无法安装
- Atomic in Redis
- 百度地图api在Html中显示,在jsp页面中不显示解决方法
- 记 Java 各版本新特性
- 彻底解决COM端口被占用(在使用中)问题的办法
热门文章
- RFS+AutoItLibrary测试Web对话框
- vim 查找与替换
- 使用OpenGL进行Mandelbrot集的可视化
- rtems 4.11 IRQ (arm,beagle)
- 下一代Apache Hadoop MapReduce框架的架构
- php解码“&;#”编码的中文用函数html_entity_decode()
- 史上最浅显易懂的Git教程2 github
- hdu2473 Junk-Mail Filter 并查集+删除节点+路径压缩
- JVM内存布局及GC知识回顾
- oracle 存储过程(1)