From: Freja Hunt on 20 May 2010 09:35 Hiya, I am trying to apply the radon transform to a block of data but dont seem to be getting the results I expect. Some of the pixels are NaNs (I am looking at vertical profiles of variable depth in the ocean so the depths occupied by topography are NaNs so all the profiles can go in one matrix) and I wondered whether this was what was causing the problem. If the radon transform doesn't work with NaNs is there anyway I can mask these pixels to prevent them for being included in the calculation without calling them NaNs? This is the code I am using: % Replace zeros at bottom of profiles where bottom topography is with NaNs. data = cube; [nt nx nz] = size(data); [a,b] = find(mask.' == 1); for i = 1:nt for j = 1:length(a) data(i,a(j),b(j)) = NaN; end end contour(data(:,:,20)) %Remove time mean zonal mean mean_t = zeros(nx,nz); for i = 1:nx mean_t(i,:) = nanmean(squeeze(data(:,i,:))).'; end for i = 1:nt data(i,:,:) = squeeze(data(i,:,:)) - mean_t; end %Apply the radon transform theta = [0:180]; for k = 1:nz R(:,:,k) = radon(squeeze(data(:,:,k)),theta); end Any suggestions are greatly appreciated
From: Matt J on 20 May 2010 09:53 "Freja Hunt" <pinkfridgee(a)hotmail.co.uk> wrote in message <ht3dqa$jd2$1(a)fred.mathworks.com>... > Hiya, > I am trying to apply the radon transform to a block of data but dont seem to be getting the results I expect. Some of the pixels are NaNs (I am looking at vertical profiles of variable depth in the ocean so the depths occupied by topography are NaNs so all the profiles can go in one matrix) and I wondered whether this was what was causing the problem. If the radon transform doesn't work with NaNs is there anyway I can mask these pixels to prevent them for being included in the calculation without calling them NaNs? =============== Couldn't you just put zeros where you have NaNs? The radon transform is just an integral, so like any integral a region of zeros will not contribute.
From: Freja Hunt on 20 May 2010 10:07 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <ht3es0$ssk$1(a)fred.mathworks.com>... > "Freja Hunt" <pinkfridgee(a)hotmail.co.uk> wrote in message <ht3dqa$jd2$1(a)fred.mathworks.com>... > > Hiya, > > I am trying to apply the radon transform to a block of data but dont seem to be getting the results I expect. Some of the pixels are NaNs (I am looking at vertical profiles of variable depth in the ocean so the depths occupied by topography are NaNs so all the profiles can go in one matrix) and I wondered whether this was what was causing the problem. If the radon transform doesn't work with NaNs is there anyway I can mask these pixels to prevent them for being included in the calculation without calling them NaNs? > =============== > > Couldn't you just put zeros where you have NaNs? The radon transform is just an integral, so like any integral a region of zeros will not contribute. Yes I guess after doing the means I could re-convert the NaNs back to noughts to apply the transform then convert them back to NaNs for further processing later in the code, but I was hoping to avoid all that extra fiddling.
From: Freja Hunt on 20 May 2010 10:17 "Freja Hunt" <pinkfridgee(a)hotmail.co.uk> wrote in message <ht3fm9$nho$1(a)fred.mathworks.com>... > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <ht3es0$ssk$1(a)fred.mathworks.com>... > > "Freja Hunt" <pinkfridgee(a)hotmail.co.uk> wrote in message <ht3dqa$jd2$1(a)fred.mathworks.com>... > > > Hiya, > > > I am trying to apply the radon transform to a block of data but dont seem to be getting the results I expect. Some of the pixels are NaNs (I am looking at vertical profiles of variable depth in the ocean so the depths occupied by topography are NaNs so all the profiles can go in one matrix) and I wondered whether this was what was causing the problem. If the radon transform doesn't work with NaNs is there anyway I can mask these pixels to prevent them for being included in the calculation without calling them NaNs? > > =============== > > > > Couldn't you just put zeros where you have NaNs? The radon transform is just an integral, so like any integral a region of zeros will not contribute. > > > Yes I guess after doing the means I could re-convert the NaNs back to noughts to apply the transform then convert them back to NaNs for further processing later in the code, but I was hoping to avoid all that extra fiddling. Also (not being very well versed in the mechanics of integrals) is the calculation of an integral dependant on the number of values? Because a NaN value wont count as a unit whereas a zero one will, which is why i used the NaNs for the mean as having extraneous zeros will affect the average value. eg mean 5 6 8 = 6.3 but mean 5 0 6 0 8 = 3.8
From: Matt J on 20 May 2010 10:23
"Freja Hunt" <pinkfridgee(a)hotmail.co.uk> wrote in message <ht3fm9$nho$1(a)fred.mathworks.com>... > Yes I guess after doing the means I could re-convert the NaNs back to noughts to apply the transform then convert them back to NaNs for further processing later in the code, but I was hoping to avoid all that extra fiddling. =============== I think you're overestimating the work it requires. These are 1-line conversions NanMap=isnan(data); %precompute the map of nans data(NanMap)=0; %convert to zeros; data(NanMap)=nan; %convert back to nans |