Jet function output error
显示 更早的评论
I got a script that is to create a flux map using two images; image of reflected rays and image of the sun. The inital lines make sense and produce an output but the total result is null (the is no flux map) after running it. I realized the
jet (ceil (max(fmap_img(:)))
did not produce anything. Any help?
4 个评论
Stephen23
2018-7-29
@KingSkido: you wrote "Jet function output error": please show us the complete error message. This means all of the red text.
WizKing
2018-7-29
Walter Roberson
2018-7-29
You can attach the script.
WizKing
2018-7-30
回答(1 个)
Image Analyst
2018-7-30
编辑:Image Analyst
2018-7-30
You must pass Jet an integer that is the number of colors it is supposed to create.
Try this:
numberOfColors = ceil (max(fmap_img(:))) % No semicolon
cmap = jet(numberOfColors) % Create a color map.
colormap(cmap); % Apply the colormap to the indexed/gray scale image.
What do you see in the command window? Does the image look pseudocolored now?
You might also want to look into caxis().
6 个评论
WizKing
2018-7-30
Walter Roberson
2018-7-30
You need to take into account that for uint8 or uint16 data type, the data value 0 is valid and means "intensity all the way at minimum".
You use the largest value in the green plane as the number of colors to use from the jet color map, but suppose the largest value is 0, then you say that the number of colors to use is 0. That is incorrect: if the largest value is 0, that means you should use 1 color. If the largest value is N then you need to use N+1 colors.
Note too that using
rcv_colormap = colormap(jet(ceil(rcv_img_max)));
colormap(rcv_colormap);
is a bit redundant. jet(ceil(rcv_img_max)) is building the colormap array, and then the colormap() call around that already puts it into effect and returns it; you do not need to colormap() it again. I would suggest you should instead
rcv_colormap = jet(ceil(rcv_img_max));
without the colormap() call at that point.
I have to wonder if using a number of colors based upon the maximum value is what you really want to do. For example when the number of colors is odd, then the middle of the jet map is always color [1/2 1 1/2] . So if you see that color on an image with (say) 101 colors then it would represent one numeric value, but if you see it on a different image with (say) 43017 values, it would represent a completely different value, making it impossible to determine absolute values by visual comparison. Is that what you want, that the colors represent relative values? Or do you want the colors to represent absolute values?
WizKing
2018-8-3
Walter Roberson
2018-8-3
Instead of
image(fmap_img)
you would use
imagesc(fmap_img, [rcv_img_min, rcv_img_max]);
WizKing
2018-8-3
编辑:Walter Roberson
2018-8-4
Walter Roberson
2018-8-4
colormap(jet)
after the above code would produce that effect.
类别
在 帮助中心 和 File Exchange 中查找有关 Color and Styling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!