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); wavelength = 20;
amplitude = 10;
phase = 0;
centreX = 0.5;
centreY = 0.5;
radius = 0; if (radius==0)
radius=min(height, width)/2;
end icentreX=width*centreX;
icentreY=height*centreY;
radius2=radius*radius;
Image_new=Image; for ii=1:height
for jj=1:width dx=jj-icentreX;
dy=ii-icentreY; distance2=dx*dx+dy*dy; if (distance2>radius2)
x=jj;
y=ii;
else
distance=sqrt(distance2);
amount=amplitude * sin(distance / wavelength * 2*pi - phase);
amount =amount* (radius-distance)/radius;
amount=amount*wavelength/(distance+0.0001); x =jj + dx*amount;
y = ii + dy*amount; 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);

参考来源:http://www.jhlabs.com/index.html

原图:

效果图:

最新文章

  1. Diwali
  2. Sqli-LABS通关笔录-13
  3. python操作memcached以及分布式
  4. How to enable logging
  5. 网络流(费用流)CodeForces 321B:Ciel and Duel
  6. java 中 final 的用法
  7. Hi3531支持2GByte内存
  8. Servlet配置与资源参数
  9. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-3禁止交换和禁用大页面
  10. MySQL--Insert Buffer
  11. 安装kubelet报错 : Depends: init-system-helpers (&gt;= 1.18~) but 1.14ubuntu1 is to be installed
  12. thinkphp5中使用PHPExcel(转载)
  13. UITableView 显示在statusbar 下面
  14. Android开发---如何操作资源目录中的资源文件
  15. java 模拟发送post请求测试
  16. 【POJ】1819.Disks
  17. 浅析VS2010反汇编
  18. HDU 1213(裸并查集)(无变形)
  19. 【mysql经典题目】行转列
  20. Win10 版本情况 201810

热门文章

  1. Struts2学习二----------访问Servlet API
  2. apt-mirror 校验错误文件处理
  3. PHP中__get()和__set()的用法实例详解
  4. 研究下JavaScript中的Rest參数和參数默认值
  5. WPF自定义选择年月控件详解
  6. 【BZOJ3544】[ONTAK2010]Creative Accounting 前缀和+set
  7. Servlet单例模式(注意)
  8. SVN设置删除权限
  9. 题解 P1095 【守望者的逃离】
  10. Android进程的生命周期