MATLAB 矩阵转化为灰度图

A=[
1.00 0.96 0.98 0.88 0.94 0.61 0.96 0.80 0.98 0.89
0.96 1.00 0.94 0.90 0.95 0.71 0.96 0.83 0.90 0.88
0.98 0.94 1.00 0.84 0.91 0.54 0.93 0.73 0.97 0.90
0.88 0.90 0.84 1.00 0.89 0.85 0.94 0.94 0.80 0.82
0.94 0.95 0.91 0.89 1.00 0.72 0.94 0.84 0.90 0.90
0.61 0.71 0.54 0.85 0.72 1.00 0.74 0.90 0.48 0.64
0.96 0.96 0.93 0.94 0.94 0.74 1.00 0.90 0.92 0.87
0.80 0.83 0.73 0.94 0.84 0.90 0.90 1.00 0.70 0.75
0.98 0.90 0.97 0.80 0.90 0.48 0.92 0.70 1.00 0.85
0.89 0.88 0.90 0.82 0.90 0.64 0.87 0.75 0.85 1.00];
mat = A; %# A n-by-n matrix of random values from 0 to 1
imagesc(mat); %# Create a colored plot of the matrix values
colormap(flipud(gray)); %# Change the colormap to gray (so higher values are
%# black and lower values are white)
textStrings = num2str(mat(:),'%0.2f'); %# Create strings from the matrix values
textStrings = strtrim(cellstr(textStrings)); %# Remove any space padding
[x,y] = meshgrid(1:10); %# Create x and y coordinates for the strings,it should be set based on the number of labels.
hStrings = text(x(:),y(:),textStrings(:),... %# Plot the strings
'HorizontalAlignment','center');
midValue = mean(get(gca,'CLim')); %# Get the middle value of the color range
set(gca,'XTick',1:10,... %# Change the axes tick marks
'XTickLabel',{'能源','材料','工业','可选消费','日常消费','医疗保健','金融','信息技术','电信服务','公共事业'},... %# and tick labels
'YTick',1:10,...
'YTickLabel',{'能源','材料','工业','可选消费','日常消费','医疗保健','金融','信息技术','电信服务','公共事业'},...
'TickLength',[0 0]);
[x,y] = meshgrid(1:10); %# Create x and y coordinates for the strings
hStrings = text(x(:),y(:),textStrings(:),... %# Plot the strings
'HorizontalAlignment','center');
midValue = mean(get(gca,'CLim')); %# Get the middle value of the color range
textColors = repmat(mat(:) > midValue,1,3); %# Choose white or black for the
%# text color of the strings so
%# they can be easily seen over
%# the background color
set(hStrings,{'Color'},num2cell(textColors,2)); %# Change the text colors
MATLAB 矩阵转化为灰度图的更多相关文章
- caffe matlab 借口怎么提取灰度图的 feature ? What happened if I mixed the color images with gray images together for training ?
1. caffe matlab 接口提供了提取feature的脚本,但是由于中间要对这些图像进行RGB ---> BGR 的变换,卧槽,灰度图没有三通道啊?怎么破?从上午就在纠结怎么会跑着跑着程 ...
- 图像处理基础---RGB图 灰度图 索引图 调色板
(1)二进制图 在二进制图中,像素的取值为两个离散数值0或1中的一个,0代表黑色,1代表白色 例 A=[0 0 1;1 1 0; 0 0 1];>> imshow(A,'InitialMa ...
- C#机器视觉入门系列1-转化为灰度图&&3*3模糊
这是我入门机器视觉的系列学习经验之开篇,本来想着依靠opencv快速实现一些功能,但是想了一下既然是学数学的,还是应该自己多算算,写一些自己理解的东西才好. 入门篇很简单,就只是实现了转化成灰度图以及 ...
- S0.2 灰度图
目录 灰度图定义 灰度图优点 RGB转灰度算法(OpenCV3) 量化 算法公式 OpenCV自带函数实现 综合比较 灰度图定义 对于单色(灰度)图像而言,每个像素的亮度用一个数值来表示,通常数值范围 ...
- 怎么样用opencv将彩色图片转化成像素值只有0和255的灰度图?
分类: OpenCV [Q1]怎么样用opencv将彩色图片转化成像素值只有0和255的灰度图? 进行灰度化,IplImage* pImg = cvLoadImage( "C:\\1.b ...
- matlab中,在灰度解剖图上叠加阈值图,by by DR. Rajeev Raizada
1.参考 reference 1. tutorial主页:http://www.bcs.rochester.edu/people/raizada/fmri-matlab.htm. 2.speech_b ...
- Matlab 如何/怎样 读取图片 显示图片 转换成灰度图
% 读取图片 im = imread('路径') >> im = imread('ny.png'); % 显示图片 imshow(im) >> imshow(im) % 转换成 ...
- python将图片转化为字符图
最近看到将图片转化为字符图的小实验,我觉得很有趣,所以决定自己实现一下. 步骤和原理如下: 读取图片的灰度值矩阵(0-255之间),灰度值矩阵主要反映的是图片的黑白程度,越黑越接近与0,越白越接近于2 ...
- MATLAB矩阵操作大全
转载自:http://blog.csdn.net/dengjianqiang2011/article/details/8753807 MATLAB矩阵操作大全 一.矩阵的表示 在MATLAB中创建矩阵 ...
随机推荐
- herf窗口点击跳转
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Building,Packaging,Deploying,and Administering Applications and Types
buliding types into a module: response files: the IL disassembler:ILDasm.exe add assemblies to a pro ...
- 《Linux内核设计的艺术》学习笔记(一)从开机加电到加载三个汇编源码
实验内核版本:0.11 ◆ 从开机到main函数的三步: ① 启动BIOS,准备实模式下的中断向量表和中断服务程序: ② 从启动盘加载OS程序到内存中,加载OS程序的工作就是利用第一步中的中断服务 ...
- html中出现的script失效
如果在Controller中出现script代码类似 $hello_str='Hello God<script>alert(3);</script>'; 那么我不希望在传给vi ...
- Codeforces723E One-Way Reform【欧拉回路】
题意:给你n点m边的图,然后让你确定每条边的方向,使得入度=出度的点最多 . 度数为偶数的点均能满足入度 = 出度. 证明:度数为奇数的点有偶数个,奇度点两两配对连无向边,则新图存在欧拉回路,则可使新 ...
- MFC编程入门之六(对话框:创建对话框模板和修改对话框属性)
本节开始为大家讲解偏向应用的知识--创建对话框. 对话框,大家应该很熟悉了,在我们常用的软件中大多都有对话框界面,例如,360安全卫士的主界面其实就是对话框,知识它做了很多美工方面的工作,将其大大美 ...
- 安卓手机与电脑无线传输文件(利用ftp服务)
安卓手机与电脑无线传输文件(利用ftp服务) 手机与电脑无线传输文件,手机开启ftp服务,电脑能够对手机内全部文件进行全方位管理,包括上传.下载.新建.删除等,而且手机和电脑能够双向传输,很方便.手机 ...
- java 零碎1
1. java 程序的入口必须是 static 类型的,接口中不允许有 static , 而且接口中的方法必须是public. 2. java 回收主要针对的是堆区的回收. 3. java.exe 是 ...
- 【bzoj1059】矩形游戏
题意 小Q是一个非常聪明的孩子,除了国际象棋,他还很喜欢玩一个电脑益智游戏--矩阵游戏.矩阵游戏在一个N*N黑白方阵进行(如同国际象棋一般,只是颜色是随意的).每次可以对该矩阵进行两种操作:行交换操作 ...
- js时间差转为天数
function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2006-12-18格式 var aDate, oDate1, oDate2, iDays aDa ...