index out of range
rocky007
I would be grateful for the suggestions. I am also attaching the full procedure.
case "Norm X":
rngopt=1
yrng=ImgRange( 1, df+"y12_norm")
Prompt yrng, "X Norm: y1,y2"
Prompt rngopt, "Norm X option:", popup, "None;Full Y"
DoPrompt "X Norm Y-range", yrng, rngopt
if (rngopt==2)
yrng=ImgRange( 1, "image") //or "axes"
endif
string/G $(df+"y12_norm")=yrng
if (V_flag==1)
SetDataFolder $curr
abort
endif
variable y1, y2
y1=NumFromList(0, yrng,",")
y2=NumFromList(1, yrng,",")
//Cursor/P A, profileV_y, x2pnt( Image, y1)
//Cursor/P B, profileV_y, x2pnt( Image, y2)
make/o/n=(nx) xtmp
SetScale/P x xmin, xinc, "" xtmp
// different methods of normalizing? NormImg in image_util??
xtmp = AREA2D( Image, 1, y1, y2, x )
Image /= xtmp[p]
cmd="Image /= xtmp[p]"
if (lockColors==0)
AdjustCT()
endif
break
rngopt=1
yrng=ImgRange( 1, df+"y12_norm")
Prompt yrng, "X Norm: y1,y2"
Prompt rngopt, "Norm X option:", popup, "None;Full Y"
DoPrompt "X Norm Y-range", yrng, rngopt
if (rngopt==2)
yrng=ImgRange( 1, "image") //or "axes"
endif
string/G $(df+"y12_norm")=yrng
if (V_flag==1)
SetDataFolder $curr
abort
endif
variable y1, y2
y1=NumFromList(0, yrng,",")
y2=NumFromList(1, yrng,",")
//Cursor/P A, profileV_y, x2pnt( Image, y1)
//Cursor/P B, profileV_y, x2pnt( Image, y2)
make/o/n=(nx) xtmp
SetScale/P x xmin, xinc, "" xtmp
// different methods of normalizing? NormImg in image_util??
xtmp = AREA2D( Image, 1, y1, y2, x )
Image /= xtmp[p]
cmd="Image /= xtmp[p]"
if (lockColors==0)
AdjustCT()
endif
break
(igor tags added by John Weeks)
First, if you use the igor tags, your code will be more readable on the forum. Is it possible some of it is missing as it is currently displayed. For example, what is the function adjustCT? This looks like it's missing or maybe it's in another procedure you use?
I think we need a bit more info to help. If you turn on the debugger, on what line is the Out of Range error thrown?
May 23, 2018 at 01:00 am - Permalink
Well, that's not a full function or macro that we could run. For instance, the definition of the variable "nx" is not within the code you posted.
When a run-time error occurs, it should tell you which line has the error. My guess is that is is the line
Image /= xtmp[p]
. My guess is that p is too big for xtmp.You can get a better idea of what's going wrong using Igor's symbolic debugger: DisplayHelpTopic "The Debugger". Right-click in your procedure window and select "Enable Debugger". Right-click again and select "Debug on Error". Now run the procedure.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 23, 2018 at 09:30 am - Permalink
May 23, 2018 at 08:41 pm - Permalink
I Have attached the full procedure and the image of the debugger result.
Thanks
May 23, 2018 at 10:03 pm - Permalink
No doubt the Index Out of Range error is coming from the use of the wave "img". The debugger is showing you that the value of axis is 1, so it must be img(y0)(x) that is going wrong. In the list "user-defined variables" you need to drage the divider between Value and Type to the right so that you can see the full information about img. You need to know the X and Y scaling of img, and compare that to the values of y0 and x. The value of y0 is 65- is that within the range of values allowed by the X scaling of img?
It appears that the SetScale operation just above the line flagged with the error should make indexing by "x" OK, except for one thing- it sets the X scaling regardless of the value of axis. I suspect you need something like this:
SetScale/P y DimOffset(img,axis), DimDelta(img,axis), "" tmp
else
SetScale/P x DimOffset(img,axis), DimDelta(img,axis), "" tmp
endif
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 24, 2018 at 10:27 am - Permalink
Best Regards,
Rocky
May 24, 2018 at 09:06 pm - Permalink
Make/O test = {0,1}
test[2] = 2 // Assign to a non-existent point - Error in Igor Pro 6.20 or later
You can turn these tests off by using rtGlobals=1 instead of rtGlobals=3. Doing this means that you are ignoring erroneous behavior, so it is not recommended as a long-term solution.
However, the file you posted, Image Tool4042.ipf, uses rtGlobals=1, so that does not explain it. It may be a different error that Igor7 detects but Igor6 did not.
If you can create a simplified, self-contained experiment that illustrates the problem, attach it and I will see if I can figure out what the problem is.
May 24, 2018 at 09:39 pm - Permalink
Hi John,
My apologies as I have not been very clear about the problem and that it has been confusing you as well as other experts here due to my presentation of the problem.
I have carried out certain operation called X-normalization which is the part of the procedure that I have attached and I have attached the pics of the results of this operation step-wise.
Capture 1- This is the original image upon which the operation is to be carried out.
Capture 2- The area is selected for which the normalization is to be carried out and is indicated by the dashed lines
Capture 3- This pic indicates the Y-coordinates of the area selected. Here, I press 'Continue' button.
Capture 4- This is where the error is generated. I have dragged the gap between 'value' and 'type' and also the image (I guess
that is the normalized one. My guess could be wrong.)
Capture 5- After I press 'GO' in Capture 4, Capture 5 comes up with the resultant pic and the error in the procedure. But my
guess is that the normalization has been carried out as you can see the difference between Capture 1 and Capture 5.
The graph on the top of the image in both the cases indicates this.
In Capture 3, the coordinates were named as y1 and y2. But in Capture 4, they are named as x1 and x2. Are you saying that the error lies here?
Now, if the resultant image is in accordance with the Normalization operation that I carried out, the what is the error trying to tell me exactly?
Now, the new development is when I changed the pragma rtGlobals from 3 to 1, no error was generated. Does that mean that the result which i got was not in accordance with the Normalization operation that I carried out?
Now, rhodstein mentioned about some erroneous behavior due to change from 3 to 1. I totally agree with him, otherwise, the procedure would not have shown any error.
But, pardon my ignorance, I am still not able to understand this so called erroneous behavior that the procedure is showing due to change from 1 to 3. Even the Igor 7 manual did not mention any error of this kind.
Warm Regards,
Srinivas
May 25, 2018 at 12:55 am - Permalink
This code:
should be changed to:
tmp= img(y0)(x)
else
tmp= img(x)(y)
endif
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
May 25, 2018 at 08:49 am - Permalink
May 25, 2018 at 10:13 am - Permalink