Matlab强迫症产生的图像
最近流行的网络迷恋的照片做头像,闲来无事,取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强迫症产生的图像相关推荐
- 图像隐藏matlab代码,picture Matlab简单操作实现图像的隐藏加密 联合开发网 - pudn.com...
picture 所属分类:其他 开发工具:Others 文件大小:15KB 下载次数:1 上传日期:2018-07-18 09:50:48 上 传 者:至尊宝物语 说明: Matlab简单操作实现图 ...
- antd tree 动态添加_一文了解Matlab如何制作动态图像
今天的推文,我们主要来介绍matlab中几种绘制动态图像的方法.首先,以之前介绍过的心形图为例,来说明在matlab中如何将绘图过程保存为gif动态图像. 1. Matlab绘制GIF图像 Step1 ...
- matlab获取目录中图像名称及路径的递归实现
一个matlab获取目录中图像名称及路径的递归实现~ matlab源文件 getImageList.m [c-sharp] view plaincopyprint? function [ imageL ...
- matlab指纹图像采集,基于MATLAB实现的指纹图像预处理
西南民族大学学报·自然科学版第 34 卷第 4 期 Journal of Southwest University for Nationalities⋅Natural Science Edition ...
- 请教如何保存matlab仿真出来的图,如何保存Matlab绘制出来的图像
该文章讲述了如何保存Matlab绘制出来的图像. Matlab提供了丰富的绘图函数,比如ez**系类的简易绘图函数,surf.mesh系类的数值绘图函数等几十个. 有网友向我反映,有时我们只有一个Ma ...
- matlab图像分类器,Matlab 基于svm的图像物体分类
Matlab 基于svm的图像物体分类 发布时间:2018-05-16 20:27, 浏览次数:1623 , 标签: Matlab svm 本周工作日志,老师布置了一个小作业,让我们使用matlab实 ...
- matlab批量处理程序设计,Matlab实现批量处理图像的两种方法
Matlab实现批量处理图像的两种方法 基本上有两个方法:一个是将你的图像统一进行一次重命名如:1.jpg,2.jpg等,然后利用for循环依次进行处理即可,如下面的语句:假设你的图像共有20副: s ...
- 使用MATLAB计算一幅图像的熵
公式 熵的计算公式: H(x)=−∑i=1nP(ai)∗logP(ai)H(x)=-\sum_{i=1}^{n}P(a_i)*logP(a_i) H(x)=−i=1∑nP(ai)∗logP(ai ...
- matlab 医学断层图像,利用MATLAB实现CT断层图像的三维重建
第 13 卷 第 2期 CT 理论与应用研究 Vol.13No.2 2004 年 5 月(24~29) CT Theory and Applications May, 2004 *收稿日期:2004- ...
最新文章
- flink搭建集群(一主三从)
- SpringCloud-Eureka-服务注册是如何发起的
- DeepMind发布Sonnet 帮你用TensorFlow快速搭建神经网络
- C#操作Excel,套用模板并对数据进行分页
- CMDB学习之三数据采集
- “父亲项目”走进澳洲校园 助父子建立联系
- web 前端(轮番插件)
- 希赛网软考学院将会使系分大大贬值
- 计算机组成原理——RAID 硬盘阵列
- 网站建设需遵循的六个步骤
- 三角学常见公式定理证明
- C++关键字分析系列
- android 悬浮球简书,Android-悬浮窗效果FloatingView
- 初学者如何选择适合自己的吉他?0基础新手男女生吉他推荐
- 学校教室计算机室云课堂软件,专注云教室教育培训云课堂的NC个人云桌面
- angular项目 ::ng-deep用法
- 冒泡法(基本原理和方法)(c语言篇)
- Unix/Linux下的Curse库开发指南——第六章 菜单开发及应用
- Stripe完善账户与使用(重点)
- Old fishman-老赵钓鱼