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. VueJS字符串反转:String.reverse()

    HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <titl ...

  2. 在 Selenium 中让 PhantomJS 执行它的 API

    from selenium import webdriver driver = webdriver.PhantomJS() script = "var page = this; page.o ...

  3. RF ---library

    RF内置库: http://robotframework.org/robotframework/ SSHLibrary:   ---WEB自动化测试 http://robotframework.org ...

  4. 当Design Support Library遇上RecycleView

    近期对Design Support Library中的一些新组件做了些研究,当中涉及到CoordinatorLayout.AppBarLayout.CollapsingToolbarLayout,为了 ...

  5. CPU调度算法

    批处理系统中的调度算法: *需要考虑的因素: 1. 吞吐量 2. cpu利用率 3. 周转时间 4. 公平性* 1.先来先服务: FCFS: 优点:实现简单 缺点:可能造成周转时间长 2.最短作业优先 ...

  6. Node.js下载及安装

    Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快.易于扩展的网络应用. Node.js 使用事件驱动, 非阻塞I/O 模型而得以轻量和高效,非常适 ...

  7. Verilog代码规范(持续更新)

    1.输入输出的定义,看起来整齐 2.always.if或其他语句后begin写在同一行,这样可以避免begin占用过多的行,代码密度更大 3.end后面要有注释,以标明是哪个关键词的结束,除了endc ...

  8. struct timeval 和 struct timespec

    struct timeval { time_t tv_sec; suseconds_t tv_usec; }; 測试代码例如以下: #include <stdio.h> #include ...

  9. a标签javascript传参不正确的解决办法!

    代码部分: <a href="javascript:void(0);" onClick="findList(${goodsClassify.id})"&g ...

  10. PHP 获取网络接口文件流

    获取网络接口里面的文件流 php开发调用各种接口在所难免,有时须要传递非常多參数. 在传递參数过程中 '&' 有时会被 解析成 '&'导致请求失败 经过查找资料和比較,发现php提供了 ...