Jet function output error
Mostra commenti meno recenti
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 Commenti
Stephen23
il 29 Lug 2018
@KingSkido: you wrote "Jet function output error": please show us the complete error message. This means all of the red text.
WizKing
il 29 Lug 2018
Walter Roberson
il 29 Lug 2018
You can attach the script.
WizKing
il 30 Lug 2018
Risposte (1)
Image Analyst
il 30 Lug 2018
Modificato: Image Analyst
il 30 Lug 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 Commenti
WizKing
il 30 Lug 2018
Walter Roberson
il 30 Lug 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
il 3 Ago 2018
Walter Roberson
il 3 Ago 2018
Instead of
image(fmap_img)
you would use
imagesc(fmap_img, [rcv_img_min, rcv_img_max]);
WizKing
il 3 Ago 2018
Modificato: Walter Roberson
il 4 Ago 2018
Walter Roberson
il 4 Ago 2018
colormap(jet)
after the above code would produce that effect.
Categorie
Scopri di più su Color and Styling in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!