Generating a filled contour colormap
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
Here is my issue. I want to make a countour with filled in level
example: say 5 level That should mean I have 5 color transitions from say Red (hot) to Blue (cold). The data I have is 1200 x 1600 monochrome png file (0-255). Range of the data was (50-125). I'm am able to generate a countour plot that has levels image one, which gave me the countours percent of max. Then I tried to fill in the countours image two and I can't get the fill to work properly. I also tryied the surf function, which gave the 3d surf but I was not able to rotate the data in the figure window to a top down view (plot would not rotate at all). Any help would be useful
Code
Z1 = imread ('\\zfcae\RenderedScene.png');
Z2 = Z1 (1:end,1:end, 1);
B = double(flipud(Z2));
Z = (smoothdata(B));
[X,Y] = meshgrid(1:1600,1:1200);
f1 = figure;
contour (Z, 10);
f2 = figure;
contourf(X,Y,Z,10)
colormap jet
f3 = figure;
h = surf (Z);
set(h,'LineStyle','none')
--- Output in sequence---
0 comentarios
Respuestas (3)
Bjorn Gustavsson
el 4 de Jun. de 2019
Instead of using surf you can use pcolor, then you get the "from-above-view" automatically. You shold have a function for doing exactly what you want: contourf, should be a drop-in replacement of contour - check the help of either to adjust the contour-levels and what-not...
HTH
0 comentarios
Michael
el 4 de Jun. de 2019
1 comentario
Bjorn Gustavsson
el 4 de Jun. de 2019
Oh, I missed that you tried contourf. It should be a drop-in replacement. Does the same single-coloured thing happen if you excplicityl command the function to draw contours at specified levels?
contourf(X,Y,Z,[linspace(50,125,7)])
Have you some other function shading the contourf in matlab, what does:
which contourf -all
return?
Pcolor maps the range of your data (Z) to the entire current colourmap. You could mimick
contourf (but will still not get exactly the same result (not the single-coloured version, but the one you want) as contourf) by reducing the numbers of colours in the colormap:
colormap(jet(7)) % or whichever colourmap you choose...
HTH
Michael
el 4 de Jun. de 2019
1 comentario
Bjorn Gustavsson
el 5 de Jun. de 2019
Seems like you've gotten a reasonably working solution - for now. I'm still a good bit curious since contourf should work. That you get an error after contourf -all is no surprice since what I wanted to know is the information about which version of contourf your matlab-session is using at that time, so could you tell us what you get after:
which contourf -all
that will tell us what version is is.
Can you share the troublesome data so that we can test in other versions?
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!