MATLAB 制作抖音同款 立体人物文字海报
效果如下:
步骤
1.导入图片并制作文字图
原图在这里:
原理就是创建一个隐藏的fig窗口,画完图后存储为图片,再调节至与原本图片相同大小
代码:
string='you are very welcome to follow my CSDN blog';
lineNum=40;%文本行数
fontSize=13;%字号
dislocation=1;%文本偏移
fontName='Helvetica';%字体
fontWeight='normal';%bold/normal是否粗体bkgPic=imread('test.jpg');
[m,n,k]=size(bkgPic);
if k~=1bkgPic=rgb2gray(bkgPic);
endif length(string)<100newString=[];repeatTimes=ceil(100/length(string));for i=1:repeatTimesnewString=[newString,' ',string];end
end
string=newString;fig=figure('units','pixels',...'position',[20 20 n m],...'Numbertitle','off',...'Color',[0 0 0],...'resize','off',...'visible','off',...'menubar','none');
ax=axes('Units','pixels',...'parent',fig,... 'Color',[0 0 0],...'Position',[0 0 n m],...'XLim',[0 n],...'YLim',[0 m],...'XColor','none',...'YColor','none');sep=m/lineNum;
i=0;
for h=sep/2:sep:mmodNum=mod(i*dislocation,length(string));tempStr=[string((1+modNum):end),string(1:modNum)];text(ax,0,h,tempStr,'Color',[1 1 1],'FontSize',fontSize,...'FontWeight',fontWeight,'FontName',fontName);i=i+1;
endsaveas(fig,'text.png');
textPic=imread('text.png');
pause(0.5)
delete('text.png')
clc;close allfigure(1)
textPic=255-textPic;
forePic=imresize(textPic,size(bkgPic));
文字图制作结果:
dislocation=1;%文本偏移
这个参数可调成别的数值,例如0的时候就意味着不偏移:
2.背景图高斯模糊
bkgPic=imgaussfilt(bkgPic,3);
3.文字图像素映射
原理和上一篇一样,可以瞅一眼:
MATLAB 制作抖音同款含褶皱面料图
代码:
exforePic=uint8(zeros(size(forePic)+[26,26,0]));
exforePic(14:end-13,14:end-13,1)=forePic(:,:,1);
exforePic(14:end-13,14:end-13,2)=forePic(:,:,2);
exforePic(14:end-13,14:end-13,3)=forePic(:,:,3);for i=1:13exforePic(i,14:end-13,:)=forePic(1,:,:);exforePic(end+1-i,14:end-13,:)=forePic(end,:,:);exforePic(14:end-13,i,:)=forePic(:,1,:);exforePic(14:end-13,end+1-i,:)=forePic(:,end,:);
end
for i=1:3exforePic(1:13,1:13,i)=forePic(1,1,i);exforePic(end-13:end,end-13:end,i)=forePic(end,end,i);exforePic(end-13:end,1:13,i)=forePic(end,1,i);exforePic(1:13,end-13:end,i)=forePic(1,end,i);
endnewforePic=uint8(zeros(size(forePic)));
for i=1:size(bkgPic,1)for j=1:size(bkgPic,2)goffset=(double(bkgPic(i,j))-128)/10;offsetLim1=floor(goffset)+13;offsetLim2=ceil(goffset)+13;sep1=goffset-floor(goffset);sep2=ceil(goffset)-goffset;c1=double(exforePic(i+offsetLim1,j+offsetLim1,:));c2=double(exforePic(i+offsetLim2,j+offsetLim2,:));if sep1==0c=double(exforePic(i+offsetLim1,j+offsetLim1,:));elsec=c2.*sep1+c1.*sep2;endnewforePic(i,j,:)=c;end
end
4.正交叠底
原理依旧和上一篇一样。。。
代码:
newforePic=uint8((double(newforePic).*double(bkgPic))./220);
imwrite(newforePic,'result.jpg')
imshow(newforePic)
5.完整代码
function characterText
string='you are very welcome to follow my CSDN blog';
lineNum=40;%文本行数
fontSize=13;%字号
dislocation=1;%文本偏移
fontName='Helvetica';%字体
fontWeight='normal';%bold/normal是否粗体bkgPic=imread('test.jpg');
[m,n,k]=size(bkgPic);
if k~=1bkgPic=rgb2gray(bkgPic);
endif length(string)<100newString=[];repeatTimes=ceil(100/length(string));for i=1:repeatTimesnewString=[newString,' ',string];end
end
string=newString;fig=figure('units','pixels',...'position',[20 20 n m],...'Numbertitle','off',...'Color',[0 0 0],...'resize','off',...'visible','off',...'menubar','none');
ax=axes('Units','pixels',...'parent',fig,... 'Color',[0 0 0],...'Position',[0 0 n m],...'XLim',[0 n],...'YLim',[0 m],...'XColor','none',...'YColor','none');sep=m/lineNum;
i=0;
for h=sep/2:sep:mmodNum=mod(i*dislocation,length(string));tempStr=[string((1+modNum):end),string(1:modNum)];text(ax,0,h,tempStr,'Color',[1 1 1],'FontSize',fontSize,...'FontWeight',fontWeight,'FontName',fontName);i=i+1;
endsaveas(fig,'text.png');
textPic=imread('text.png');
pause(0.5)
delete('text.png')
clc;close allfigure(1)
textPic=255-textPic;
forePic=imresize(textPic,size(bkgPic));bkgPic=imgaussfilt(bkgPic,3);%bkgPic
%imshow(bkgPic)exforePic=uint8(zeros(size(forePic)+[26,26,0]));
exforePic(14:end-13,14:end-13,1)=forePic(:,:,1);
exforePic(14:end-13,14:end-13,2)=forePic(:,:,2);
exforePic(14:end-13,14:end-13,3)=forePic(:,:,3);for i=1:13exforePic(i,14:end-13,:)=forePic(1,:,:);exforePic(end+1-i,14:end-13,:)=forePic(end,:,:);exforePic(14:end-13,i,:)=forePic(:,1,:);exforePic(14:end-13,end+1-i,:)=forePic(:,end,:);
end
for i=1:3exforePic(1:13,1:13,i)=forePic(1,1,i);exforePic(end-13:end,end-13:end,i)=forePic(end,end,i);exforePic(end-13:end,1:13,i)=forePic(end,1,i);exforePic(1:13,end-13:end,i)=forePic(1,end,i);
endnewforePic=uint8(zeros(size(forePic)));
for i=1:size(bkgPic,1)for j=1:size(bkgPic,2)goffset=(double(bkgPic(i,j))-128)/10;offsetLim1=floor(goffset)+13;offsetLim2=ceil(goffset)+13;sep1=goffset-floor(goffset);sep2=ceil(goffset)-goffset;c1=double(exforePic(i+offsetLim1,j+offsetLim1,:));c2=double(exforePic(i+offsetLim2,j+offsetLim2,:));if sep1==0c=double(exforePic(i+offsetLim1,j+offsetLim1,:));elsec=c2.*sep1+c1.*sep2;endnewforePic(i,j,:)=c;end
endnewforePic=uint8((double(newforePic).*double(bkgPic))./220);
imwrite(newforePic,'result.jpg')
imshow(newforePic)end
5.其他成品展示
注:图片需选择深色背景图片以避免过度迁移,同时在选择其它图片时应对代码最前面字体,字号,文本行数进行调整,若图片尺寸过小,需要将高斯模糊的第二个参数调小(sigma)
注意:
2016版及以前不支持高维数组与二维数组点乘,因此请将105行附近代码:
newforePic=uint8((double(newforePic).*double(bkgPic))./220);
更改为:
newforePicR=(double(newforePic(:,:,1)).*double(bkgPic))./220;
newforePicG=(double(newforePic(:,:,2)).*double(bkgPic))./220;
newforePicB=(double(newforePic(:,:,3)).*double(bkgPic))./220;
newforePic(:,:,1)=newforePicR;
newforePic(:,:,2)=newforePicG;
newforePic(:,:,3)=newforePicB;
newforePic=uint8(newforePic);
即对三个通道分别处理后再进行合并
MATLAB 制作抖音同款 立体人物文字海报相关推荐
- MATLAB 制作抖音同款旋转星空海报图
大概像是下面这样(我是真的不会设计海报,大家凑乎着看叭) 我们要制作的就是上面这样的背景图,文章最后由完整代码 步骤 1.导入图片 导入图片并获得长宽及通道数信息,图片需要和m文件在同一文件夹: I= ...
- MATLAB 制作抖音同款炫光海报
这篇其实步骤比较多,看效果: 步骤 0.图片导入 oriPic=imread('test.jpg'); 原始图片: 抖音上是做了铜板雕刻的像素化处理,由于MATLAB本身不具备这个功能,因此我们使用添 ...
- MATLAB 制作抖音同款故障风海报
效果: 步骤 1.参数设定及图片导入 可以只更改背景图片其实 bkgPic=imread('test.jpg');%图片地址 lineDensity=0.6; %故障线条出现概率 lineLenRan ...
- MATLAB 制作抖音同款含褶皱面料图
效果如下:!!! 步骤 1.导入图片 我们需要导入一张褶皱图片(background.jpg)以及一张前景图片(foreground.jpg),将褶皱图片灰度化,将前景图调整至与褶皱图片相同大小: b ...
- MATLAB 制作抖音同款突出效果海报
效果如下: 步骤 1.导入图片,获取每个区域的平均颜色,构造随机数矩阵 导入图片后我们首先将图片划分成很多个15x15(可自行调整大小)的小格子,并求取每个格子的颜色平均值,作为柱状图每个小柱子的颜色 ...
- Python制作抖音同款含褶皱面料图
写在前面的话. 之前在码友slandarer的CSDN主页https://blog.csdn.net/slandarer看到他用MATLAB实现了几个有趣的图片处理趣案例,一时技痒,斗胆留言我也要用p ...
- 利用JS制作抖音同款3D照片墙(three.js)
利用JS制作抖音同款3D照片墙(three.js) 520快到了,跟我一起学习threeJS 用threeJS制作抖音同款3D照片墙 源码下载:3D照片墙源码下载地址
- 细说如何制作抖音同款性格测试,运气测试网站(带代码讲解)
Hi,大家好!我是你们活泼又可爱的小虎! 最近抖音很火的什么性格测试,运气值测试之类的,小虎研究了一下,发现了其中的奥秘!!! 开始说了,小板凳准备好了吗? 本来想给大家照几张样图,但是刷了半小时,就 ...
- Unity 制作抖音同款 罗马时钟
这个罗马时钟 好像出来好久了在某音上,刚看到 觉得很 好玩,所以自己就想着实现一下 效果. 下面直接上图 先说一下制作思路:1. 文本的放置位置.2.时间的获取 和校正. 3. Text随着时间的刷新 ...
最新文章
- session 与 cookie的区别
- extern C 在c 与 cxx间的使用
- 基于hi-nginx的web开发(python篇)——cookie和会话管理
- 标题在图表上_Excel 2010基础应用:图表的创建与编辑
- android学习笔记---asm.jar的使用方法--手机真机屏幕同步抓取软件
- 深度学习的半精度浮点数的运用
- 6.业务架构·应用架构·数据架构实战 --- 双轮驱动的技术架构设计
- whoosh读取+html,django-haystack+jieba+whoosh实现全文检索
- 【MATLAB】MATLAB基本运算
- 我的毕业论文————面向对象的软件测试
- Mcafee杀毒软件卸载不了
- ODC预制光纤连接器
- zotero如何用markdown记笔记
- [附源码]java毕业设计房屋租赁管理系统
- 网页游戏mysql修改_大天使之剑奇迹网页游戏 一键服务端+架设教程+修改方法
- 阿玛机器人_豪华日本声优阵容,《战斗天赋解析系统》让你耳朵怀孕!
- nandwrite 参数
- 生僻字如何用计算机打出来,巧妙的运用Word输入生僻字
- 西门子s7 计算机通讯,S7-1200与电脑网线通讯-工业支持中心-西门子中国
- 成就系统实现(三)-架构设计
热门文章
- usb转ttl 一直显示正在检测目标单片机 ...的解决方法
- 9 个超实用的 JavaScript 原生插件工具
- alin的学习之路:序列化与protobuf
- 无人驾驶大巴试车_中国无人驾驶汽车高速公路试车成功
- 求解,某M1水卡数据计算分析/大神们求指导!
- 【ML4CO论文精读】具有离散拆分送货和取货的车辆路径问题的禁忌搜索算法(Meng Qiu, 2018)
- 从“人类简史”到“未来简史”:为什么 AI 会带来工作岗位的爆发?
- MEM/MBA数学基础(06)数列
- R语言与多元线性回归+逐步回归
- java 浏览器发送传真_java---------发送网络传真