Tue, 02/14/2017 - 03:54 pm
Hi I have a 2048 by 2048 matrix from X (pixels), Y(Binning), and Z(Intensity)-2D data. I want to modify this matrix (X, Pixel only) with a quadratic equation (for instance, 0.002*x^2-0.4*x+940) where x represents row number for rows (e.g. 300 to 500). The resultant matrix should be able to provide an image. Does anyone have idea or code to solve such type of problem in Igor? Will much appreciate the help.
If you are just trying to creating an image from an equation this little bit of code can get you started. Three windows are created on top of each other with three different images.
Make/O/N=(2048, 2048) TestImage1=0, TestImage2=0, TestImage3=0
TestImage1[][]=0.002*p^2-0.4*p+940
TestImage2[][]=0.002*p^2-0.4*q+940
TestImage3[300, 500][]=0.002*p^2-0.4*q+940
DoWindow/K TestImageWindow1
Display/N=TestImageWindow1;AppendImage TestImage1
ModifyImage '' ctab= {*,*,ColdWarm,0}
DoWindow/K TestImageWindow2
Display/N=TestImageWindow2;AppendImage TestImage2
ModifyImage '' ctab= {*,*,ColdWarm,0}
DoWindow/K TestImageWindow3
Display/N=TestImageWindow3;AppendImage TestImage3
ModifyImage '' ctab= {*,*,ColdWarm,0}
end
February 15, 2017 at 01:03 am - Permalink
I want to distort the x-axis of an existing image so that NewX=0.002*OldX^2-0.4*OldX+940. The Y and Z should remain the same.
February 15, 2017 at 08:34 am - Permalink
Make/O/N=(2048, 2048) TestImage1=0
Make/O/N=2049 XWave1, YWave1 // The x- and y-waves indicates the corners of the pixels and is therefore one point larger than the image
TestImage1[][]=sin(8*pi/2048*p)
XWave1[]=p-0.5
YWave1[]=p-0.5
XWave1[]=0.002*p^2+0.4*p+940 // Has to be monotonically increasing or decreasing. I changed -0.4*p to +0.4*p to ensure that
DoWindow/K TestImageWindow1
Display/N=TestImageWindow1; AppendImage TestImage1 vs {XWave1, YWave1}
// Converts the image to waveform
Variable XStart=2000,XStep=1,XEnd=9000,YStart=500,YStep=1,YEnd=1500
ImageInterpolate /DEST=TestImage2 /S={XStart,XStep,XEnd,YStart,YStep,YEnd} /W={XWave1, YWave1} XYWaves TestImage1
// Sets the x and y scaling of the new wave
SetScale/P x, XStart, XStep, "", TestImage2
SetScale/P y, YStart, YStep, "", TestImage2
DoWindow/K TestImageWindow2
Display/N=TestImageWindow2; AppendImage TestImage2
end
February 16, 2017 at 12:59 am - Permalink
February 16, 2017 at 04:47 pm - Permalink
Make/O/N=(2048, 2048) TestImage1=0
Make/O/N=2049 XWave1, YWave1 // The x- and y-waves indicates the corners of the pixels and is therefore one point larger than the image
TestImage1[][]=sin(8*pi/2048*p)
XWave1[]=p-0.5
YWave1[]=p-0.5
XWave1[]=0.002*p^2+0.4*p+940 // Has to be monotonically increasing or decreasing. I changed -0.4*p to +0.4*p to ensure that
DoWindow/K TestImageWindow1
Display/N=TestImageWindow1; AppendImage TestImage1 vs {XWave1, YWave1}
end
The
AppendImage TestImage1 vs {XWave1, YWave1}
line is the important one. You can tryAppendImage TestImage1
instead to compare the effect of the x- and y-waves.February 17, 2017 at 12:28 am - Permalink
I tried both of the codes in my system. I am having trouble getting the result I wanted.
February 19, 2017 at 10:37 am - Permalink