Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: write images to different folders
Replies: 2   Last Post: Dec 11, 2012 12:42 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
GITTO THAMPI

Posts: 3
Registered: 12/7/12
Re: write images to different folders
Posted: Dec 11, 2012 12:42 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Steven_Lord" <slord@mathworks.com> wrote in message <k9suib$mgu$1@newscl01ah.mathworks.com>...
>
>
> "GITTO THAMPI" <gittothampi@yahoo.in> wrote in message
> news:k9sefn$qal$1@newscl01ah.mathworks.com...

> > i'm doing a work in frame extraction from video. i want to save the
> > extracted frames to many subfolders that exists in a particular
> > location(not current directory). I want to save the first 75 extracted
> > frames in subfolder1, the next 75 frames in subfolder2, and so on... this
> > is the code i have written..
> >
> > xyloObj = mmreader('F:short\mov1.mpg');
> >
> > nFrames = xyloObj.NumberOfFrames;
> > disp(nFrames);
> > n=1;
> > % Read one frame at a time.
> >
> > for j = 1 : (nFrames/75)
> > foldername=strcat('mov1seg',int2str(j));
> > f1=fullfile('F:xylo\mov1\',foldername);

>
> So f1 starts with F:xylo\mov1\mov1seg1 and continues with
> F:xylo\mov1\mov1seg2, etc. [BTW you may be missing a \ just after F:]
>

> > mkdir(f1);
>
> The directory is created.
>

> > for k=n: n+74
> > mov(k).cdata = read(xyloObj, k);
> > mov(k).colormap = [];
> > %imshow(mov(k).cdata);
> > imagename=strcat(int2str(k), '.jpeg');
> > imwrite(mov(k).cdata, strcat('F:xylo\mov1\mov1seg',int2str(j),imagename));

>
> This doesn't do quite what you think it does. Let's say j = 1 and k = 1.
> What does the STRCAT call return?
>
> j = 1;
> k = 1;
> imagename=strcat(int2str(k), '.jpeg');
> whereToWrite = strcat('F:xylo\mov1\mov1seg',int2str(j),imagename)
>
> F:xylo\mov1\mov1seg11.jpeg
>
> That's NOT where you wanted to write the file. You're missing the separator
> between the directory name and the file name. Some comments:
>
> 1) You already have the first part of your STRCAT call; you defined it above
> as f1. Why recreate that string in your IMWRITE call? Just use f1!
> 2) You used FULLFILE in the construction of f1. Why didn't you use it
> instead of STRCAT? FULLFILE handles adding in the separator automatically.
>
> imwrite(mov(k).cdata, fullfile(f1, imagename));
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


thanks a lot.. it works well..



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.