Jet function output error
Show older comments
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 Comments
Stephen23
on 29 Jul 2018
@KingSkido: you wrote "Jet function output error": please show us the complete error message. This means all of the red text.
WizKing
on 29 Jul 2018
Walter Roberson
on 29 Jul 2018
You can attach the script.
WizKing
on 30 Jul 2018
Answers (1)
Image Analyst
on 30 Jul 2018
Edited: Image Analyst
on 30 Jul 2018
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 Comments
WizKing
on 30 Jul 2018
Walter Roberson
on 30 Jul 2018
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
on 3 Aug 2018
Walter Roberson
on 3 Aug 2018
Instead of
image(fmap_img)
you would use
imagesc(fmap_img, [rcv_img_min, rcv_img_max]);
WizKing
on 3 Aug 2018
Edited: Walter Roberson
on 4 Aug 2018
Walter Roberson
on 4 Aug 2018
colormap(jet)
after the above code would produce that effect.
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!