clc;
clear all;
close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread('4.jpg');
I=double(I);
Image=I/255; sz=size(Image); % set the parameters
radius = 150;
angle = pi/4;
angle2=pi/4;
sides=10;
centerX = 0.5; % set the center of the circle, proportion of the image size
centerY = 0.5; iWidth=sz(2);
iHeight=sz(1); icenterX=iWidth*centerX;
icenterY=iHeight*centerY; Image_new=Image; for i=1:sz(1)
for j=1:sz(2) dx=j-icenterX;
dy=i-icenterY; r=sqrt(dy*dy+dx*dx);
theta=atan2(dy, dx)-angle-angle2; temp_theta=theta/pi*sides*0.5 ;
theta=triangle(temp_theta); if (radius)
c=cos(theta);
radius_c=radius/c;
r=radius_c * triangle(r/radius_c);
end theta=theta+angle; x=r * cos(theta)+icenterX;
y=r * sin(theta)+icenterY; if (x<=1) x=1; end
if (x>=sz(2)) x=sz(2)-1; end;
if (y>=sz(1)) y=sz(1)-1; end;
if (y<1) y=1; end; % % % if (x<=1) continue; end
% % % if (x>=sz(2)) continue; end;
% % % if (y>=sz(1)) 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 滤镜— — 万花筒效果的更多相关文章

  1. Python: PS 滤镜--万花筒效果

    本文用 Python 实现 PS 的一种滤镜效果,称为万花筒.也是对图像做各种扭曲变换,最后图像呈现的效果就像从万花筒中看到的一样: 图像的效果可以参考之前的博客: http://blog.csdn. ...

  2. PS 滤镜— —挤压效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  3. PS 滤镜— —Marble 效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  4. PS 滤镜— —水波效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  5. PS 滤镜— — sparkle 效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  6. PS 滤镜— —球面化效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  7. PS滤镜— —波浪效果

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  8. OpenCV——PS滤镜 水波效果

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  9. Python: PS 滤镜--旋涡特效

    本文用Python 实现 PS 滤镜的旋涡特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/42215 ...

随机推荐

  1. 关于meta标签的name="viewport" 概述

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scal ...

  2. winform 下载文件显示进度和百分比

    /// <summary> /// 下载完成 /// </summary> private void DownloadFileCompleted() { IsComlate = ...

  3. ubuntu 12.10 笔记

    笔记 more ec_unitouch.log |grep Thread-4 筛选日志 打开命令行终端 ctrl + alt + t     查看版本号 : sudo lsb_release -a t ...

  4. jQuery 插件开发(1)

    JavaScript 是一门混乱的语言,好的特性和坏的特性混杂在一起.而不同浏览器对标准的解析不一致,使得这门语言更加混乱,在这种情况下遵循最佳实践有诸多好处,至少不会掉入坑里.所以就有了<Ja ...

  5. import org.marker.weixin.DefaultSession; import org.marker.weixin.HandleMessageAdapter; import org.marker.weixin.MySecurity; import org.marker.weixin.msg.*;

    需要以下微信包可以添加我的微信公众号 回复“微信api”即可得到jar链接,以及maven添加本地jar方法,以及更改后的源代码 import org.marker.weixin.DefaultSes ...

  6. fastjson(转)

    博客地址 :http://blog.csdn.NET/shulianghan/article/details/41011605 fastjson 源码地址 : -- GitHub : https:// ...

  7. 网络新闻传输协议NNTP

    一.Usenet与新闻组 Usenet新闻系统是一个全球存档的“电子公告板”,各种主题的新闻组一应俱全.新闻组可以是面向全球泛泛而谈,也可以是只面向某一个地区区域. 整个系统是由一个大量计算机组成的一 ...

  8. DOM相关操作的案例

    1 . 模态框案例 示例 :  打开网页时有一个普通的按钮,点击当前按钮显示一个背景图,中心并弹出一个弹出框,点击X的时候会关闭当前的模态框 <!DOCTYPE html> <htm ...

  9. java 解析excle

    jjava解析excle或者csv文件并导出到web界面: 创建ExcelShower.java package com.ssm.controller; import java.io.File; im ...

  10. Quartz Job scheduling 基础实现代码

    Quartz 集成在 SpringBoot 中分为 config.task.utils.controller 和 MVC 的三层即 controller.service.dao 和 entity. c ...