Using "image interpolation" to subtract images with different scales.
Hello,
Sorry for my lack of knowledge.
I'm trying to subtract waves with different scaling, but the spectral features are getting totally out of place with the simple code I wrote. I cut the waves at the same scale points, but the dimensions and wave scaling are unmatched. The result is shown in the red and blue scale image below, the red intense negative value should be at the center.
•Duplicate/R=(-1.6,1.6)(-1.2414,1.2414) '3Cr_FSmap24_bkgnor' '3Cr_FSmap_nr'
•Duplicate/O '3Cr_FSmap_nr' diff3Cr_BFA
•diff3Cr_BFA -= BCA_FSmap_nr
•Display;DelayUpdate
•AppendImage diff3Cr_BFA
•ModifyImage diff3Cr_BFA ctab= {-6,6,RedWhiteBlue256,0}
I tried to use ImageInterpolation to create new waves with the same scaling and dimensions, but with no success. I was trying the simplest thing possible, but it returned "syntax error".
ImageInterpolate/FUNC=nn resample BCA_FSmap_nr
I tried also a different interpolation method, but it returned "Insufficient input". Obviously, I dont understand the use of this method.
Make/O/N=(DimSize(BCA_FSmap_nr,1)) yBFA= DimOffset(BCA_FSmap_nr,1)+X*DimDelta(BCA_FSmap_nr,1)
ImageInterpolate /W={xBFA,yBFA} /F={2,2} /FDS XYWaves, BCA_FSmap_nr
So, apparently, I'm trying to do a simple task with advanced tools that I dont know how to use. If anyone has a suggestion it would be appreciated.
What are the scalings for the two source images? Your picture suggests that both source images have the same x,y ranges but different DimDelta values. If so, you will need to convert one or the other (or both) to a common DimDelta value before subtraction. This is done either by downsampling the larger sized image or by upsampling the smaller sized image.
What are the bit depths for each image? Once you have the scaling issue resolved, you may do better to convert the images to float before subtracting, then convert the result back to the desired bit depth.
April 3, 2023 at 08:27 am - Permalink
I don't know, but can you just do:
•diff3Cr_BFA -= BCA_FSmap_nr(x)(y)
This should select the points at the correctly scaled values. Note that this just looks for the nearest points and does not interpolate the images, but if your data is sufficiently fine-grained this should be good enough. Otherwise you would need to interpolate your data first to match the sizes in both dimensions.
April 3, 2023 at 10:29 am - Permalink
I recommend using ImageInterpolate to interpolate one of the images to match the resolution of the other image. Simple subtraction would then work.
I'd like to caution that in general, we are used to the expression wave(someValue) as a simple linear interpolation. That works in 1D but it is not the case in more than one dimension.
A.G.
April 3, 2023 at 02:15 pm - Permalink
In reply to What are the scalings for… by jjweimer
I think the images are already in float format. The original waves, without my cropping, are as follow:
April 4, 2023 at 06:10 am - Permalink
In reply to I don't know, but can you… by chozo
This works way better than what I had before, thanks
April 4, 2023 at 06:13 am - Permalink