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 Commenti

Stephen23
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
WizKing il 29 Lug 2018
@Stephen Cobeldick oh, i should have written jet function null output. There is no output at all, I really meant. Please can I email you the full script?
Walter Roberson
Walter Roberson il 29 Lug 2018
You can attach the script.
WizKing
WizKing il 30 Lug 2018
@Walter Robertson. Okay

Accedi per commentare.

Risposte (1)

Image Analyst
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
WizKing il 30 Lug 2018
@
@Image analyst. There was a change but not what I expected, I have attached the script in my comment at @Walter Robertson's answer. Please look through as well I might have omitted something entirely.
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
WizKing il 3 Ago 2018
@Walter Roberson Great! Thanks for the 8 bit data consideration alert. I have also implemented the N+1 number of color. I now have [rcv_img_max + 1 ] as the argument for the ceil() call. But after I did that, I'm still getting only color blue as the output and a white & blue in the color bar.
And yes, I want the colors to represent relative values.(I am comparing values) This is what I am actually doing. I am creating a flux map of sun rays reflected unto a receiver using the image of the sun as a calibration.
Instead of
image(fmap_img)
you would use
imagesc(fmap_img, [rcv_img_min, rcv_img_max]);
WizKing
WizKing il 3 Ago 2018
Modificato: Walter Roberson il 4 Ago 2018
Okay please I have done that.
Also, after the colormap() call. I want to create a surface that looks like:
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
% surface in 3D
figure;
surf(Z,'EdgeColor','None'); view(2)% surface in 2D
Using the colormap() output in the script. So that the red will be the centre color (peak), followed by yellow up to blue in a concentric circular transition.
colormap(jet)
after the above code would produce that effect.

Accedi per commentare.

Categorie

Richiesto:

il 29 Lug 2018

Community Treasure Hunt

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

Start Hunting!

Translated by