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
0 件のコメント
採用された回答
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 件)
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;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!