- indexed color images (direct colormapping)
- pseudocolor representations of arbitrarily-scaled data (scaled colormapping)
How to Apply Jet Colormap to Montage?
16 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have been trying to apply the Jet colormap to a set of images (see attached file) to then display them using the function montage. Montage() has an option to input the desired colormap for the images one wants to display. However, I keep getting errors. So, does any of you know how I can display the set of images with the Jet map applied using the montage function?
Thank you in advance for your help. I highly appreciate it.
0 个评论
采纳的回答
DGM
2023-9-26
编辑:DGM
2023-9-26
There are two places where color tables are used:
montage() and imshow() perform #1 when fed a color table. You want #2.
The solution depends on what your data looks like and how you're trying to represent it. You haven't told us how you were doing the mapping, what the errors were, or what the end goal is. If you want each page mapped with respect to its own extrema (as you would with imagesc(), then no, montage() is the wrong tool. If the goal is to produce a composite image and save it, montage() isn't helpful for that either.
Here are two examples.
load QCStimVol.mat
map = jet(256);
% visualize all pages using the same extrema (global)
% imshow()/montage() do scaled mapping when the input is 2D
% the map will be gray() by default, but is otherwise specified externally
% this is equivalent to reshaping the array and displaying it with imshow()
inrange = imrange(QCStimVol); % global extrema
montage(QCStimVol,'displayrange',inrange) % specify the input range
colormap(map) % specify the map
% visualize the pages using their own extrema (local)
% use the attached files to construct the RGB data
nslices = size(QCStimVol,3);
pcolorslices = cell(nslices,1);
for k = 1:nslices
thisslice = QCStimVol(:,:,k);
inrange = imrange(thisslice); % local extrema
pcolorslices{k} = gray2pcolor(thisslice,map,inrange,'cdscale');
end
montage(pcolorslices)
In either case, montage() is a visualization tool, not a composition tool. If you want to actually save the resulting image, use imtile() and imwrite(), not montage(). If this is the goal, then both global and local mapping would need to be done similar to the second example, since imtile() cannot generate the pseudocolor image by itself.
% global mapping
nslices = size(QCStimVol,3);
pcolorslices = cell(nslices,1);
inrange = imrange(QCStimVol); % global extrema
for k = 1:nslices
thisslice = QCStimVol(:,:,k);
pcolorslices{k} = gray2pcolor(thisslice,map,inrange,'cdscale');
end
outpict = imtile(pcolorslices); % build the composite image
imwrite(outpict,'global.png') % save it
% local mapping
nslices = size(QCStimVol,3);
pcolorslices = cell(nslices,1);
for k = 1:nslices
thisslice = QCStimVol(:,:,k);
inrange = imrange(thisslice); % local extrema
pcolorslices{k} = gray2pcolor(thisslice,map,inrange,'cdscale');
end
outpict = imtile(pcolorslices); % build the composite image
imwrite(outpict,'local.png') % save it
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!