Creating a 3D surface plot from array data

33 views (last 30 days)
I have this script
clear
img = imread('cameraman.tif');
Mean = 0.01:0.01:0.05;
hsize = 3:1:25;
for m = 1:length(Mean)
for h = 1:length(hsize)
V=0.01;
noise = imnoise(img,'gaussian',Mean(m),V);
[peaksnr, snr] = psnr(noise,img);
nsr = 1/snr;
PSF = fspecial('average',hsize(h));
AverageBlur = imfilter(img,PSF,'replicate','same','conv');
NoiseyBlurred = imfilter(noise,PSF,'replicate','same','conv');
NoiseyBlurredImage = NoiseyBlurred;
BlindDeconv = deconvblind(NoiseyBlurredImage,PSF,15);
LucyFilter = deconvlucy(NoiseyBlurredImage,PSF,15);
WNRFilter = deconvwnr(NoiseyBlurredImage,PSF,nsr);
RegularFilter = deconvreg(NoiseyBlurredImage,PSF,NPowerInt);
PSNRBlurred = psnr(NoiseyBlurredImage,img);
PSNRBlind = psnr(BlindDeconv,img);
PSNRLucy = psnr(LucyFilter,img);
PSNRWNR = psnr(WNRFilter,img);
PSNRReg = psnr(RegularFilter,img);
Blur(h,m)= (40-PSNRBlurred)/40;
Blind(h,m)=PSNRBlind;
Lucy(h,m)=PSNRLucy;
WNR(h,m)=PSNRWNR;
Reg(h,m)=PSNRReg;
end
end
It saves the PSNR value for each hsize and mean in 25x5 array like this:
Lucy =
21.6467 21.4919 21.1253 20.7971 20.3298
22.2624 22.1446 21.7016 21.3296 20.7955
22.4250 22.1990 21.8411 21.4450 21.0195
Each column has 25 values which i cut short for space. The blurred error (denoted 'Blur') saves in the same way.
I am trying to plot a 3D surface/mesh of the data, where for each column PSNR vs error is plotted, rather than just a 2D line plot with 5 lines over the top of eachother. Is there a way to do this?
Edit: Attached Image of 2D plot to help with clarity of the question. Can i make a graph like this but 3D to be able to see all the lines (ideally as a surface) and with the new axis being the 'Mean'. The 5 lines are due to the 5 Mean values. The error and psnr value changes with each hsize, i.e. 23 x,y values per line. Allowing me to see how both hsize and mean affect the PSNR value.
Apologies for the lack of clarity and specificity in the original question, hopefully this helps clear things up.

Accepted Answer

Star Strider
Star Strider on 30 Apr 2020
Try this:
figure
surf(Lucy)
grid on
or:
figure
mesh(Lucy)
grid on
The ‘x’ and ‘y’ axes are in units of the relevant indices, since ‘x’ and ‘y’ vectors or matrices defining them otherwise are not provided.
  6 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!