PS 滤镜— —扇形warp
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
原图
效果图
PS 滤镜— —扇形warp的更多相关文章
- Python: PS 滤镜--扇形变换
本文用 Python 实现 PS 滤镜中的一种几何变换特效,称为扇形变换,将图像扭曲成一个扇形,具体的算法原理和效果图可以参考以前的博客: http://blog.csdn.net/matrix_sp ...
- OpenCV——PS 滤镜, 浮雕效果
具体的算法原理可以参考: PS 滤镜, 浮雕效果 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITH ...
- OpenCV——PS 滤镜, 曝光过度
算法原理可以参考: PS 滤镜,曝光过度 #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <io ...
- Python: PS 滤镜--水波特效
本文用 Python 实现 PS 滤镜中的 水波特效 import numpy as np from skimage import img_as_float import matplotlib.pyp ...
- Python: PS 滤镜--旋涡特效
本文用Python 实现 PS 滤镜的旋涡特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/42215 ...
- Python: PS 滤镜--USM 锐化
本文用 Python 实现 PS 滤镜中的 USM 锐化效果,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/detail ...
- Python: PS 滤镜--素描
本文用 Python 实现 PS 滤镜中的素描特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/386 ...
- Python: PS 滤镜--表面模糊
本文用 Python 实现 PS 滤镜中的表面模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/528 ...
- Python: PS 滤镜--旋转模糊
本文用 Python 实现 PS 滤镜中的旋转模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/392 ...
随机推荐
- hdu1081 最大子矩阵
最大子矩阵自然直在最大连续子序列的升级版 只是其原理都是用到了动态规划思想 仅仅是矩阵用到了枚举 +合并 把非常多列看成是一列的和 #include<stdio.h> ...
- Synchronized修饰静态变量和普通变量的区别
这里主要涉及到类对象(static方法),对象方法(非static方法) 我们知道,当synchronized修饰一个static方法时,多线程下,获取的是类锁(即Class本身,注意:不是实例): ...
- PHP网站常见安全漏洞 及相应防范措施总结
一.常见PHP网站安全漏洞 对于PHP的漏洞,目前常见的漏洞有五种.分别是Session文件漏洞.SQL注入漏洞.脚本命令执行漏洞.全局变量漏洞和文件漏洞.这里分别对这些漏洞进行简要的介绍. 1.se ...
- 根据URL发起HTTP请求,我的HTTPHelper。
完整的demo using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- Docker入门系列2 安装
可以从 Docker 社区直接下载可用的模版或镜像. Docker容器的启动可以在秒级实现,这相比传统的虚拟机方式要快得多. 其次,Docker对系统资源的利用率很高,一台主机上可以同时运行数千个Do ...
- git连接到github(SSH无密码登陆)
[0]README 0.1)本文旨在尝试在linux环境下免密码连接到github,并进行push + pull projects in github by git commands. 0.1) 对s ...
- linux程序设计——网络信息(第十五章)
15.3 网络信息 当眼下为止,客户和server程序一直是吧地址和port号编译到它们自己的内部. 对于一个更通用的server和客户程序来说.能够通过网络信息函数来决定应该使用的地址和por ...
- python 基础 2.7 range与xrange的区别
#/usr/bin/python #coding=utf-8 #@Time :2017/10/25 19:22 #@Auther :liuzhenchuan #@File :range与xrange的 ...
- JS之字符串与JSON转换
JS之字符串转换JSON 1.eval 古老的方式 function strToJson(str){ var json = eval('(' + str + ')'); return json; ...
- 性能测试--测试流程、APDEX、linux性能知识
测试流程.APDEX.linux性能知识 一.性能测试流程: 整体流程:收集需求-->搭建测试环境-->设计性能测试场景-->开发测试脚本-->执行测试-->收集数据-- ...