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