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) BCA_FSmap24_bkgnor BCA_FSmap_nr
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,0)) xBFA= DimOffset(BCA_FSmap_nr,0)+X*DimDelta(BCA_FSmap_nr,0)
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.

I don't know, but can you just do:

Duplicate/O '3Cr_FSmap_nr' diff3Cr_BFA
•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.

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.

In reply to by jjweimer

I think the images are already in float format. The original waves, without my cropping, are as follow:

 

Wave: BCA_FSmap24_bkgnor
Type: Single Float 32 bit
Rows: 800  Start: -1.79401  Delta: 0.00455653  Units: pi/a
Columns: 57  Start: -1.23641  Delta: 0.0442355  Units: pi/a

 

 

Wave: 3Cr_FSmap24_bkgnor
Type: Single Float 32 bit
Rows: 800  Start: -1.76966  Delta: 0.00449467  Units: pi/a
Columns: 57  Start: -1.21962  Delta: 0.043635  Units: pi/a