11-09-2016 12:44 PM
Hi! I have a folder containing several images, I need to select the first, read it, do some processing stuff and then pick up the second and do the same thing in a loop, how can I do that?
The images are called for example as:
"acquisitionL0-14-31-54"
"acquisitionL1-14-31-57"
"acquisitionL2-14-31-58" and so on...
when the last 3 numbers are hours/minutes/seconds of acquistion
I have Labview 2016 with vision toolbox
Solved! Go to Solution.
11-09-2016 12:53 PM
11-09-2016 02:15 PM
ok, thank you, it seems working
11-09-2016 02:47 PM
I did like this:
However I noticed just now that the order is:
aquisitionL118
aquisitionL119
aquisitionL12
aquisitionL121
aquisitionL122 ....
******
aquisitionL128
aquisitionL129
aquisitionL13
aquisitionL131
aquisitionL132
which is not correct : /
11-09-2016 07:26 PM
If you want to view the images in an order specified by an ordering of the filename, then you need to appropriately sort the list of filenames. The list that you show is, in fact, "dictionary-sorted", since "3" comes after "123". If you are making up the file names yourself and are "counting" them (1, 2, 3, ...), then you can use the count as part of the name if you format it with sufficient leading zeros. That is, if you know you'll never have 1000 files, you could number them 001, 002, 003, etc., which puts 003 way before 123 and solves your "ordering" problem. Otherwise, you'll need to parse (take apart) the name, find the numeric part, and sort on that (tricky coding).
Bob Schor
11-13-2016 06:32 AM
The problem is that filenames are already those and i cannot remake the experiment so can't generate new data with another name, so I have to handle with these names
11-13-2016 09:56 AM
I'm confused by your posts, as you seem to have two conflicting series of names for your files. The original post suggested that the names were of the form <CommonTextString><Number>-<2-digit Hour>-<2-digit Minute>-<2-digit Second>. The fact that the numbers following the CommonTextString (which is either "AcquisitionL" or "AquisitionL") are separated by hyphens makes parsing simpler. The first number seems to be a sequence, suggesting that the remaining 3 can be ignored, but that's also not clear.
What do you want as a "sorting rule"? I'm assuming that you are not renaming anything (despite the names in the second post being completely different from the names in the first).
A "trick" that can help with a "Parse-sort" is to take your array of Names and create an array of Clusters consisting of a (unique) number based on the Name, which I'll call the "Indexer", and the Name. If the Indexer is the first element of the Cluster, then if you sort this array, you'll be sorting the Names as you want. So in one For Loop, you take a Name, create the Cluster, and build the Array of Clusters, you sort the Cluster, then in the second For loop, you retrieve the Name part, ending with a (sorted) Array of Names.
So it call comes down to creating the Indexer. Let's assume the format is the following: "Bob2-9-11-12", where the name starts with "Bob", has a number representing who-knows-what (but first in sort order), then a time in H, M, S, all the numbers separated by hyphens. Use Scan from String to isolate the four numbers -- if you feed the string in, use a Format string of "Bob%d-%d-%d-%d", and ask for four I32 outputs, you would get 2, 9, 11, 12. Now you want a unique sortable number, which you can get by adding 2*1000000 + 9*10000 + 11*100 + 12 = 2091112. Do you get the idea?
Bob Schor
11-13-2016 03:07 PM
Windows Explorer -> Right-click -> Rename
As it stands, that oder makes perfect sense. Why can't you use basic Windows dunctionality to rename the files?
If you have a valid reason, it'll be on you to write a quick algorithm to sort through your array of names and put them in your desired order.
11-14-2016 07:50 AM
At the end I solved rearranging the strings in the order I wanted:
11-14-2016 10:03 AM - edited 11-14-2016 10:03 AM
While I'm disappointed you didn't follow the suggestions for how to (easily) sort your set of filenames, you did seem to answer the question that the first number is, indeed, the index. Just in case someone with a similar problem stumbles on this post and is tempted to use your awkward method, I'm posting what I (and others) had hoped you would try, a method that works even if (as in my simple example) some elements are missing. Even you should admit this method is much simpler and easier to understand.
Bob Schor