Matlab生成强迫症图片
来源:互联网 发布:映客号是什么软件 编辑:程序博客网 时间:2024/04/28 18:29
最近网络上流行强迫症图片做头像,闲来无事,拿matlab弄了一个生成器,可以生成包含0-9以及99+的强迫症。
原理很简单,可以直接用两幅图叠加,这里为了减少文件,将数字图片保存在.mat二进制文件中。
=====================================================================================================
代码如下:
clear,clc%% open image file[fn,pn,fi]=uigetfile('*.bmp;*.png;*.jpg;*.jpeg','choose image');img=imread([pn fn]);%% process image width = size(img,1);%image widthheight = size(img,2);%image heightminlength = min([width,height]);%min of width and heightcircle_d = floor(minlength*(1-0.618));%circle radiuscircle_x_end = circle_d;circle_y_start = height - circle_d + 1;%circle centercircle_center_x = circle_x_end/2;circle_center_y = (circle_y_start+height)/2;%draw circle--------------------------------for i=1:circle_x_end for j=circle_y_start:height if((i-circle_center_x)^2+(j-circle_center_y)^2 <= (circle_d/2)^2) img(i,j,1) = 255; img(i,j,2) = 0; img(i,j,3) = 0; end endend% draw number-------------------------------load number.matnum = input('Input the number to add to the image:');while(num<0 || num>9) num = input('Input error,out of range(0-9),reinput the number:'); end%-------------------------------------------%scale the nu7mber imagevar_name = ['number' num2str(num)];eval([var_name '=imresize(' var_name ',[circle_x_end,height - circle_y_start+1]);']);%sharp the imageeval(['index = find(' var_name '>0);']);for k=1:length(index) eval([var_name '(index(k)) = 255;']);end%add the value to the 2nd and 3rd layereval(['img(1:circle_x_end,circle_y_start:height,2) = img(1:circle_x_end,circle_y_start:height,2)+' var_name ';']);eval(['img(1:circle_x_end,circle_y_start:height,3) = img(1:circle_x_end,circle_y_start:height,3)+' var_name ';']);%% show imageimshow(img);%% save imagedotindex = max(find(fn=='.'));imwrite(img,[fn(1:dotindex-1) ' with number ' num2str(num) fn(dotindex:end)]);
=====================================================================================================
另外数字的二进制文件随代码一起上传在此(点击此处下载)
效果图如下:
2 0
- Matlab生成强迫症图片
- 强迫症图片
- 强迫症
- 强迫症
- 强迫症
- 用Matlab批量生成图片
- matlab 连续图片生成AVI视频
- matlab 图片序列 生成 avi视频
- matlab生成图片清晰插入论文
- 信息化的强迫症
- 测试覆盖率强迫症
- 我的强迫症
- 资料下载强迫症
- 微软的强迫症?
- 强迫症 解题报告
- 强迫症的HelloWord!
- 完美主义强迫症诊断
- 愚人节 之强迫症描述
- markdown 最简单入门
- 【转】IE6下Line-height失效问题
- 你可能并不需要消息队列
- opentack neutron环境
- WebView
- Matlab生成强迫症图片
- ActionContext和ServletActionContext小结
- python面向对象1
- Java工厂模式实例
- mysql数据恢复-mysqlbinlog
- VC++ 计时器
- uva 704(隐式图搜索)
- 我大学学的计算机、毕业在网吧当了两年网管、是在想学点技术、再也不当屌丝网管来了!!!
- 电脑死机故障分析