what is the map in this example?

조회 수: 2 (최근 30일)
Mingli Liang
Mingli Liang 2023년 12월 27일
이동: Dyuman Joshi 2023년 12월 29일
when I try to run this code in MATLB, it doesn't work in which showing cant find the variable of map for colormap(map). does anyone know what the map is here?
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 12월 27일
이동: Dyuman Joshi 2023년 12월 29일
The variable map is part of the file mri.mat -
%Check the file location
which mri.mat
/MATLAB/toolbox/matlab/demos/mri.mat
load mri.mat
%check the contents loaded into the workspace (ignore cmdout)
whos
Name Size Bytes Class Attributes D 128x128x1x27 442368 uint8 cmdout 1x33 66 char map 89x3 2136 double siz 1x3 24 double
A generally preferred is to load the data into a variable -
out = load('mri.mat')
out = struct with fields:
D: [128×128×1×27 uint8] map: [89×3 double] siz: [128 128 27]

댓글을 달려면 로그인하십시오.

답변 (2개)

Chunru
Chunru 2023년 12월 27일
편집: Chunru 2023년 12월 27일
"map" specifies the color of the image.
load mri
Name Size Bytes Class Attributes D 128x128x1x27 442368 uint8 cmdout 1x33 66 char map 89x3 2136 double siz 1x3 24 double

DGM
DGM 2023년 12월 27일
편집: DGM 2023년 12월 27일
Ah. This is one of the hazards of using load() like this.
When you run the line
load mri
... you're loading the contents of mri.mat into memory. Three new variables magically appear in the workspace without ever being declared anywhere in the code.
One of the three is the variable called map. It is an 89x3 gray colormap. The map is almost perfectly linear and full-scale, so if you really wanted to, it would probably suffice to replace it with gray(89), but that shouldn't be necessary. Check to make sure you're loading mri.mat and that the contents are showing up in the workspace.

카테고리

Help CenterFile Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by