Clear Filters
Clear Filters

pcolor - how to smooth

56 views (last 30 days)
Yuji Zhang
Yuji Zhang on 30 Aug 2013
Answered: Usenobong Akpan on 15 Mar 2019
Hi everyone~
I'm plotting some contour map (x, y, z)
If I use Origin, it does some nice smoothing.
In Maltab, using
pcolor(x, y, z); shading interp;
It shows all the noise.
See the picture please.<>
The 3rd plot is a comparison: when data's not noisy, Matlab produces a flat background part (the blue part) too.
I wonder if there's anyway I can get do the same as in Origin using Matlab. Or do I have to smooth the data myself?
Any thoughts are appreciated. Thanks~

Answers (3)

Kelly Kearney
Kelly Kearney on 30 Aug 2013
Pretty sure it's just a colormap difference, with origin setting everything less than -90 to black. Try this:
shading interp;
set(gca, 'clim', [-90 -32]);
colormap([0 0 0; jet]);
You'll probably have to fiddle a bit more with the colormap and color limits to get the exact same thing, but that should be close.
  1 Comment
Yuji Zhang
Yuji Zhang on 30 Aug 2013
Hi Kelly~
Thanks for your help. The method to change the low-background color is helpful~
The graph I provided was misleading. My question was actually: the low signal part (black part in 2nd graph) has noise. In the 1st graph the noise is all shown. I don't want it to show.
See the comparison: the 3rd graph is where there's no noise, the blue part is flat.
Please see the updated picture. Thank you~

Sign in to comment.

Image Analyst
Image Analyst on 30 Aug 2013
Can you somehow get an image out of that? Because images are a lot easier to smoother than a list of random coordinates.
Yuji Zhang
Yuji Zhang on 30 Aug 2013
Hi~ Thank you for your help! Sure I got picture. The graph I uploaded is a picture.
I'm not familiar with imagine processing. I can't imagine smoothing a picture is easier than smoothing the data. Could you give me a link or something that I can learn how to smooth a picture from? Or could you just download the picture I provided and show me an example of smoothing(if it's easy and quick)? Thanks a lot~
Image Analyst
Image Analyst on 30 Aug 2013
Edited: Image Analyst on 30 Aug 2013
One way, though not necessarily the best way is to just use convolution to blur each color channel one at a time:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
windowSize = 7;
kernel = ones(windowSize) / windowSize ^ 2;
% Blur the individual color channels.
smoothedPictureR = conv2(double(redChannel), kernel, 'same');
smoothedPictureG = conv2(double(greenChannel), kernel, 'same');
smoothedPictureB = conv2(double(blueChannel), kernel, 'same');
% Recombine separate color channels into a single, true color RGB image.
smoothrgbImage = uint8(cat(3, smoothedPictureR , smoothedPictureG, smoothedPictureB));

Sign in to comment.

Usenobong Akpan
Usenobong Akpan on 15 Mar 2019
Please I am a new user of matlab. i need help on the matlab code that would make me plot a single 3 axes graph. I am comparing power (W) and temp (degree celsius) over same time interval. I can if there were of the same unit i.e. W and W over same time interval; but here I am having difficulty.
pls can anyone help out?


Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!