ImageLoad not working in loop
aahemm
Hello:
more and more questions are arising ...
Variable refNum
Variable i
String fileFilterStr = "Images (*.jpg):.jpg, .jpeg;"
Open /D /R /F=fileFilterStr /MULT=1 refNum
for(i=0; i<ItemsInList(S_fileName, "\r"); i=i+1)
Print(StringFromList(i, S_fileName, "\r"))
ImageLoad /Q /T=jpeg (StringFromList(i, S_fileName, "\r"))
endfor
Variable i
String fileFilterStr = "Images (*.jpg):.jpg, .jpeg;"
Open /D /R /F=fileFilterStr /MULT=1 refNum
for(i=0; i<ItemsInList(S_fileName, "\r"); i=i+1)
Print(StringFromList(i, S_fileName, "\r"))
ImageLoad /Q /T=jpeg (StringFromList(i, S_fileName, "\r"))
endfor
I'm trying to load a series of jpeg images. Therefor I call the Open-function (with /MULT=1) and get a string with all selected file names, separated by "\r". I split up this string using the function above and try to load all image into waves, named like the files.
If I comment out the ImageLoad call, the script goes through all names in the S_fileName and print it properly. If I "comment in" the ImageLoad call it just does the first image and then quits or opens the open dialogue like no file name is provided.
What am I doing wrong?
Thanks for your help,
Axel.
The problem is that ImageLoad sets S_fileName. It is a good idea to copy output variables such as S_fileName to local variables immediately after calling an operation. For example:
Variable refNum
Variable i
String fileFilterStr = "Images (*.jpg):.jpg, .jpeg;"
Open /D /R /F=fileFilterStr /MULT=1 refNum
String filePathList = S_fileName
Variable numItems = ItemsInList(filePathList, "\r")
for(i=0; i<numItems; i=i+1)
String filePath = StringFromList(i, filePathList, "\r")
Print i, filePath
ImageLoad /Q /T=jpeg filePath
endfor
End
I also recommend using local variables such as "filePath" above as it makes it easier to debug code. You can see the value of filePath in the debugger but you can not see the value of StringFromList(i, filePathList, "\r") in the debugger.
July 30, 2018 at 05:13 am - Permalink
//gives error in IGOR 6.37 when used inside a function
are sure sir this will work. I am Facing problems in HDF5LoadData call here is the link : https://www.wavemetrics.com/forum/general/hdf5-issues-when-trying-open-…
any help will be greatly appreciated
August 4, 2018 at 12:34 am - Permalink