最近流行的网络迷恋的照片做头像,闲来无事,取matlab获取一个建设者,它可以产生包括0-9以及99+OCD。

原理很easy,图叠加,这里为了降低文件,将数字图片保存在.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 width
height = size(img,2);%image height
minlength = min([width,height]);%min of width and height
circle_d = floor(minlength*(1-0.618));%circle radius
circle_x_end = circle_d;
circle_y_start = height - circle_d + 1;
%circle center
circle_center_x = circle_x_end/2;
circle_center_y = (circle_y_start+height)/2;
%draw circle--------------------------------
for i=1:circle_x_endfor j=circle_y_start:heightif((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;endend
end
% draw number-------------------------------
load number.mat
num = 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 image
var_name = ['number' num2str(num)];
eval([var_name '=imresize(' var_name ',[circle_x_end,height - circle_y_start+1]);']);
%sharp the image
eval(['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 layer
eval(['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 image
imshow(img);
%% save image
dotindex = max(find(fn=='.'));
imwrite(img,[fn(1:dotindex-1) ' with number ' num2str(num) fn(dotindex:end)]);

=====================================================================================================

另外数字的二进制文件随代码一起上传在此(点击此处下载)

效果图例如以下:

版权声明:本文博客原创文章,博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/lcchuguo/p/4724512.html

Matlab强迫症产生的图像相关推荐

  1. 图像隐藏matlab代码,picture Matlab简单操作实现图像的隐藏加密 联合开发网 - pudn.com...

    picture 所属分类:其他 开发工具:Others 文件大小:15KB 下载次数:1 上传日期:2018-07-18 09:50:48 上 传 者:至尊宝物语 说明:  Matlab简单操作实现图 ...

  2. antd tree 动态添加_一文了解Matlab如何制作动态图像

    今天的推文,我们主要来介绍matlab中几种绘制动态图像的方法.首先,以之前介绍过的心形图为例,来说明在matlab中如何将绘图过程保存为gif动态图像. 1. Matlab绘制GIF图像 Step1 ...

  3. matlab获取目录中图像名称及路径的递归实现

    一个matlab获取目录中图像名称及路径的递归实现~ matlab源文件 getImageList.m [c-sharp] view plaincopyprint? function [ imageL ...

  4. matlab指纹图像采集,基于MATLAB实现的指纹图像预处理

    西南民族大学学报·自然科学版第 34 卷第 4 期 Journal of Southwest University for Nationalities⋅Natural Science Edition ...

  5. 请教如何保存matlab仿真出来的图,如何保存Matlab绘制出来的图像

    该文章讲述了如何保存Matlab绘制出来的图像. Matlab提供了丰富的绘图函数,比如ez**系类的简易绘图函数,surf.mesh系类的数值绘图函数等几十个. 有网友向我反映,有时我们只有一个Ma ...

  6. matlab图像分类器,Matlab 基于svm的图像物体分类

    Matlab 基于svm的图像物体分类 发布时间:2018-05-16 20:27, 浏览次数:1623 , 标签: Matlab svm 本周工作日志,老师布置了一个小作业,让我们使用matlab实 ...

  7. matlab批量处理程序设计,Matlab实现批量处理图像的两种方法

    Matlab实现批量处理图像的两种方法 基本上有两个方法:一个是将你的图像统一进行一次重命名如:1.jpg,2.jpg等,然后利用for循环依次进行处理即可,如下面的语句:假设你的图像共有20副: s ...

  8. 使用MATLAB计算一幅图像的熵

    公式 熵的计算公式: H(x)=−∑i=1nP(ai)∗logP(ai)H(x)=-\sum_{i=1}^{n}P(a_i)*logP(a_i) H(x)=−i=1∑n​P(ai​)∗logP(ai​ ...

  9. matlab 医学断层图像,利用MATLAB实现CT断层图像的三维重建

    第 13 卷 第 2期 CT 理论与应用研究 Vol.13No.2 2004 年 5 月(24~29) CT Theory and Applications May, 2004 *收稿日期:2004- ...

最新文章

  1. flink搭建集群(一主三从)
  2. SpringCloud-Eureka-服务注册是如何发起的
  3. DeepMind发布Sonnet 帮你用TensorFlow快速搭建神经网络
  4. C#操作Excel,套用模板并对数据进行分页
  5. CMDB学习之三数据采集
  6. “父亲项目”走进澳洲校园 助父子建立联系
  7. web 前端(轮番插件)
  8. 希赛网软考学院将会使系分大大贬值
  9. 计算机组成原理——RAID 硬盘阵列
  10. 网站建设需遵循的六个步骤
  11. 三角学常见公式定理证明
  12. C++关键字分析系列
  13. android 悬浮球简书,Android-悬浮窗效果FloatingView
  14. 初学者如何选择适合自己的吉他?0基础新手男女生吉他推荐
  15. 学校教室计算机室云课堂软件,专注云教室教育培训云课堂的NC个人云桌面
  16. angular项目 ::ng-deep用法
  17. 冒泡法(基本原理和方法)(c语言篇)
  18. Unix/Linux下的Curse库开发指南——第六章 菜单开发及应用
  19. Stripe完善账户与使用(重点)
  20. Old fishman-老赵钓鱼

热门文章

  1. 5g网络模式是以什么划分的_问答:5G手机需要支持哪些网络模式和频段?
  2. 使用python进行数据清洗及ols回归分析
  3. bilibili2020 1024ctf安全挑战赛(上)
  4. picasa lingoes(灵格斯) 冲突
  5. Lingoes对Chrome的支持
  6. Unity中的点乘和叉乘
  7. 创建maven模板Java项目
  8. k8s使用的网络连接
  9. 2021年高处安装、维护、拆除考试报名及高处安装、维护、拆除考试资料
  10. 十面埋伏(DFS,标记)