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中创建矩阵 ...
随机推荐
- FJNU 1152 Fat Brother And Integer(胖哥与整数)
FJNU 1152 Fat Brother And Integer(胖哥与整数) Time Limit: 1000MS Memory Limit: 257792K [Description] [题 ...
- python_way day14 HTML
python_way day 14 HTML 一,标签 二.特殊字符 三,css <!DOCTYPE html> <html lang="en"> < ...
- 委托、匿名方法、Lambda表达式的演进
摘自:"http://www.cnblogs.com/eagle1986/archive/2012/01/19/2327358.html 假设给我们一个泛型对象List<T>,T ...
- iOS - OC SQLite 数据库存储
前言 采用 SQLite 数据库来存储数据.SQLite 作为一中小型数据库,应用 iOS 中,跟前三种保存方式相比,相对比较复杂一些. 注意:写入数据库,字符串可以采用 char 方式,而从数据库中 ...
- iOS - UIPickerView
前言 NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UIPickerView : UIView <NSCoding, UITa ...
- c++ 复习练习
复习c++的时候,发现一篇 如何通过c++ primer学习c++的好文,并列出了一些建议的练习题目. 链接,http://blog.csdn.net/solstice/article/details ...
- Doragon Kuesuto 1.15
#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { ; ; ; int actio ...
- Js获取当前日期时间及格式化操作
var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1 ...
- ElasticSearch(ES)和solr的关系和区别
可以参考这篇文章:http://www.cnblogs.com/chowmin/articles/4629220.html Solr 2004年诞生(当时是Solar). ElasticSearch ...
- 一张图看懂360°全景和VR的区别
2016年开始,Facebook.谷歌.腾讯.阿里等互联网巨头都已开始抢食VR(虚拟现实)这块的大蛋糕,虚拟现实发展速度惊人.在这样强势发展的背景下,一些产品也开始打着VR的幌子,挂着VR的噱头卖起来 ...