Make the colours of my graph continuous

8 次查看(过去 30 天)
Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I've already tried using shading interp or patch but I can't manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault

采纳的回答

DGM
DGM 2023-12-13
编辑:DGM 2023-12-13
There's nothing to blur, because you're not creating a raster image. The only raster image is the screenshot, and blurring a screenshot makes even less sense.
Bear in mind that you appear to be trying to create an image of a particular size (2268x3402), but the rendered image size is completely arbitrary. Not even the aspect ratio is preserved. Given that the axis rulers are hidden, I don't see why the image size even matters here. If you want a pseudocolor image of a particular size, taking a screenshot of the entire figure is not going to let you do that.
Attached is a version which does the work without using fill(). The variable thisT is a 2268x3402 array of temperature data. For sake of consistency with the demonstrated workflow, this 2D data is rendered with imagesc(), a colorbar and title, and a screenshot is saved. The image geometry is still lost because the result is a screenshot.
If you want an actual 2268x3402 pseudocolor image, then that's a different story. Attached is another copy which generates plain images instead of screenshots.
In both cases, the graduation is purely a result of the linear interpolation from 3x9 to 2268x3402. Whether that makes technical sense or not, I don't know. Since we're working with raster images, you could always do the interpolation in other ways, or you could do other sorts of filtering after resizing.
Oh. I forgot to mention that I ran the code through a translator. Given that the translator returned hilariously invalid code the first time, I'm not inclined to try to translate it back again.
  1 个评论
Jan Soller
Jan Soller 2023-12-13
Thank you so much for your reply and all the details. The result is superb!
Don't worry about the translation, I'll manage XD.
Thanks again for everything, I'll be able to adjust the final settings thanks to you!!

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2023-12-13
I would just blur the image before displaying it.
windowWidth = 15; % Whatever....
blurKernel = ones(windowWidth, windowWidth) / windowWidth^2;
blurredImage = uint8(conv2(single(indexedImage), blurKernel, 'same'));
imshow(blurredImage);
colormap(turbo);
colorbar;

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by