473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Image sequence listing ...

Am not sure if it's been asked before (did a search but didn't come up
with anything
related...).
I'm trying to write some code to "collapse" image sequences into
a single item , i.e.:
image.1.exr
image.2.exr
....
image.100.exr

into
image.[1-100].exr

This is for display only so i do not show up 100 files but only one
as some file managers do.

Anyone got any info on doing this quickly ?

I use Boost already in my app, so I guess the regex boost lib could
help
but not really sure of the most efficient way of doing it
Dec 20 '07 #1
5 2141
ma*********@gmail.com wrote:
Am not sure if it's been asked before (did a search but didn't come up
with anything
related...).
I'm trying to write some code to "collapse" image sequences into
a single item , i.e.:
image.1.exr
image.2.exr
...
image.100.exr

into
image.[1-100].exr

This is for display only so i do not show up 100 files but only one
as some file managers do.

Anyone got any info on doing this quickly ?
What's your C++ language question? Are you trying to declare an array
to help you manage the sequence? You can also do it using 'std::map'
or 'std::vector', but I am unsure what to recommend since you didn't
show any code, and C++ doesn't have a definition of "image", nor does
it have a definition of "collapsing" of those.
I use Boost already in my app, so I guess the regex boost lib could
help
but not really sure of the most efficient way of doing it
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 20 '07 #2
On Dec 20, 12:43 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
majestik...@gmail.com wrote:
Am not sure if it's been asked before (did a search but didn't come up
with anything
related...).
I'm trying to write some code to "collapse" image sequences into
a single item , i.e.:
image.1.exr
image.2.exr
...
image.100.exr
into
image.[1-100].exr
This is for display only so i do not show up 100 files but only one
as some file managers do.
Anyone got any info on doing this quickly ?

What's your C++ language question? Are you trying to declare an array
to help you manage the sequence? You can also do it using 'std::map'
or 'std::vector', but I am unsure what to recommend since you didn't
show any code, and C++ doesn't have a definition of "image", nor does
it have a definition of "collapsing" of those.
I use Boost already in my app, so I guess the regex boost lib could
help
but not really sure of the most efficient way of doing it

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Well I guess my c++ question is about
how do you list a folder, and while doing that
collapsing the filenames that are in the form prefix.%d.suffix
into "groups" like prefix.[first-last].suffix
it's not image related really, just about how to work out
the strings to collapes into one.
Dec 20 '07 #3
ma*********@gmail.com wrote:
[..]
Well I guess my c++ question is about
how do you list a folder, and while doing that
collapsing the filenames that are in the form prefix.%d.suffix
into "groups" like prefix.[first-last].suffix
it's not image related really, just about how to work out
the strings to collapes into one.
Ah... OK. Folders aside, files aside, your question is what you
should do to form "blah.[N-M].blah" if you have a bunch of strings
all containing "blah.<N>.blah", "blah.<N+1>.blah", etc., until the
"blah.<M>.blah" where N and M are two numbers. Right?

This is not a C++ language question. It's an algorithm question.
You need an algorithm for string processing. I would probably
suggest something like

// find the beginning of the sequence
int N;
for (N = 0; N < INT_MAX; ++N) {
std::ostringstream os;
os << "prefix." << N << ".suffix";
std::string filename(os.str());
if (/* exists the file with pattern 'filename' */)
break;
}
// now N is your start
int M;
for (int M = N; M<INT_MAX; ++M) {
std::ostringstream os;
os << "prefix." << M << ".suffix";
std::string filenam(os.str());
if (/* does NOT exist file with pattern 'filename' */)
break;
}
if (--M N) { // got the sequence!
std::ostringstream os;
os << "prefix.[" << N << '-' << M << "].suffix";
return os.str(); // here you go
}
else { // it's a single file, maybe.
...
}

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 20 '07 #4
On Dec 20, 1:27 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
majestik...@gmail.com wrote:
[..]
Well I guess my c++ question is about
how do you list a folder, and while doing that
collapsing the filenames that are in the form prefix.%d.suffix
into "groups" like prefix.[first-last].suffix
it's not image related really, just about how to work out
the strings to collapes into one.

Ah... OK. Folders aside, files aside, your question is what you
should do to form "blah.[N-M].blah" if you have a bunch of strings
all containing "blah.<N>.blah", "blah.<N+1>.blah", etc., until the
"blah.<M>.blah" where N and M are two numbers. Right?

This is not a C++ language question. It's an algorithm question.
You need an algorithm for string processing. I would probably
suggest something like

// find the beginning of the sequence
int N;
for (N = 0; N < INT_MAX; ++N) {
std::ostringstream os;
os << "prefix." << N << ".suffix";
std::string filename(os.str());
if (/* exists the file with pattern 'filename' */)
break;
}
// now N is your start
int M;
for (int M = N; M<INT_MAX; ++M) {
std::ostringstream os;
os << "prefix." << M << ".suffix";
std::string filenam(os.str());
if (/* does NOT exist file with pattern 'filename' */)
break;
}
if (--M N) { // got the sequence!
std::ostringstream os;
os << "prefix.[" << N << '-' << M << "].suffix";
return os.str(); // here you go
}
else { // it's a single file, maybe.
...
}

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
well yes it's the problem, but the initial conditions are a bit
different
let's say i have a list of strings in the form you mentioned
prefix.<N>.suffix, I can have different prefixes etc.
but I guess I cannot avoid going through the files one by one
and looking if i can join it with other files in the same folder.
Dec 20 '07 #5
ma*********@gmail.com wrote:
On Dec 20, 1:27 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>majestik...@gmail.com wrote:
>>[..]
Well I guess my c++ question is about
how do you list a folder, and while doing that
collapsing the filenames that are in the form prefix.%d.suffix
into "groups" like prefix.[first-last].suffix
it's not image related really, just about how to work out
the strings to collapes into one.

Ah... OK. Folders aside, files aside, your question is what you
should do to form "blah.[N-M].blah" if you have a bunch of strings
all containing "blah.<N>.blah", "blah.<N+1>.blah", etc., until the
"blah.<M>.blah" where N and M are two numbers. Right?

This is not a C++ language question. It's an algorithm question.
You need an algorithm for string processing. I would probably
suggest something like

// find the beginning of the sequence
int N;
for (N = 0; N < INT_MAX; ++N) {
std::ostringstream os;
os << "prefix." << N << ".suffix";
std::string filename(os.str());
if (/* exists the file with pattern 'filename' */)
break;
}
// now N is your start
int M;
for (int M = N; M<INT_MAX; ++M) {
std::ostringstream os;
os << "prefix." << M << ".suffix";
std::string filenam(os.str());
if (/* does NOT exist file with pattern 'filename' */)
break;
}
if (--M N) { // got the sequence!
std::ostringstream os;
os << "prefix.[" << N << '-' << M << "].suffix";
return os.str(); // here you go
}
else { // it's a single file, maybe.
...
}

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

well yes it's the problem, but the initial conditions are a bit
different
let's say i have a list of strings in the form you mentioned
prefix.<N>.suffix, I can have different prefixes etc.
but I guess I cannot avoid going through the files one by one
and looking if i can join it with other files in the same folder.
It's all in how you check for the existence of the file. If your
system allows enumerating with a pattern (like "*.1001.img"), then
you're in luck and you need to put the asterisk instead of 'prefix'.

The algorithm as I wrote it is also substandard from the performance
point of view. It would be nice if you could simply get all the
strings (names of the files) fitting the pattern "*.[0-9]+.suffix",
and sort them while disregarding the prefix (you need a custom
comparison functor for that). Then you simply have an array of
strings, and the very first one contains your N, which you can
simply extract from the string itself. And you can simply keep
extracting the number from each string and compare it to what you
expect (previous + 1). If it isn't, your sequence is over, and
you may need to start another sequence...

Anyway, this doesn't seem to be a C++ topic either. Try posting to
comp.programming, the general algorithm discussion newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I'm still learning javascript - I've invested in a couple of books and reading online as much as possible. I'm pretty sure what I am suggesting is possible though I'm trying to weigh up...
13
by: lkrubner | last post by:
Suppose I need to get an image as a stream of bytes. I want to store this in a variable and then embed it in some Postscript code. In my Postscript code, the image might look like this: {<...
5
by: Camet | last post by:
I have been trying to create a dynamic id for a number of images in a table so that I can identify which image was clicked on later. ie I need to set a variable to the id of each image, that is...
11
by: Richard | last post by:
All I want to do is to read a list of the image files in my folder and display them on a page. That way I don't have to re-write the page, I can just upload extra images. I don't need fancy...
6
by: Frank Rizzo | last post by:
I have an interesting problem. I have a directory of image files. However, none of the files have an extension. I need to figure out what type if image it is and attach an extension to the file. ...
1
by: oruccim | last post by:
hi I want understanding pictures colorfull for examle colorfull or black-white image.google.com there are understand it .Can I understand it thanks....
20
realin
by: realin | last post by:
hiya guys, I have a question, i want to display the image which is above the page, while my script loads in the background. This is a simple script which check for new messages in my mailbox,...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
2
by: studentofknowledge | last post by:
For some unknown reason ie is placing images I have in a div in a weird way. One image is overlapping another but this problem is not occuring in mozilla. I have looked at my code over and over again...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.