Calculate mean from three different matrices when condition applies

1 view (last 30 days)
I want to calculate mean from the images S1,S2,S3 where land is equal to one.Is it a correct way of writing it? and later I want to have the scatterplot. I want to have S1-mean, S2-mean and S3-mean on my x axis.
S1 = imread('vv240_60.tif'); S2 = imread('hv104_60m.tif'); S3 = imread('hv240_60.tif'); land = imread('land.tif');
Mean = nanmean(S1,S2,S3( land == 1 ));
x = S1-Mean; % how can I merge the data of all 3 matrices for x? y = Tbv- ME_crop_v;
scatter(x,y,'MarkerFaceColor','g','MarkerEdgeColor','g');

Answers (1)

Image Analyst
Image Analyst on 29 Sep 2014
Why are you using nanmean? Are there nans in the data? That's in the Stats toolbox I believe so I can't run it.
I'm not sure what two variables you're scattering. It looks like you're scattering the gray levels against y but I have no idea what y is or how to obtain it. Having millions of datapoints, because that's probably how many pixels you have, is not good for scatter - will probably take a very long time.
To get individual means you can do this
mean1 = mean(S1(land==1));
mean2 = mean(S2(land==1));
mean3 = mean(S3(land==1));
After that I don't know what to do because I don't know what y is and why you want millions of scatter points.
  2 Comments
Hana
Hana on 29 Sep 2014
Thanks for your reply. yes I have nan values thats why I used nanmean. Please dont bother about y. My question is that how I can plot x which is from 3 images?
Image Analyst
Image Analyst on 29 Sep 2014
x is an image. What does it mean to "plot" it? Or to scatter it, when you need two things to scatter? I know how to display x (with image, imshow, or imagesc), but to plot it like a curve on an x,y chart? I don't know what that means. Please explain.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!