Save image in specific location (directory)

I am loading a video file, then saving indivdual frames as jpg images.
I ask the user of the script to locate and open the video file:
% Ask user to open video file
[baseFileName, folderName, FilterIndex] = uigetfile('*.*', 'Select Video File');
if ~isequal(baseFileName, 0)
movieFullFileName = fullfile(folderName, baseFileName);
else
return;
end
Once matlab does its thing, I want to be able to write an image to the same directory as the video file came from.
imwrite(frame,"frame.jpg") % + something to write in the proper place
Is this possible?

 채택된 답변

Voss
Voss 2024년 1월 29일

0 개 추천

Specify the full path to write to:
imwrite(frame,fullfile(folderName,"frame.jpg"))
Of couse, if that line is located in a different function than the function that defines folderName (i.e., the function where uigetfile is called), then you'll need to store folderName as an app property (App Designer) or in the handles structure (GUIDE) or otherwise make folderName accessible where you need it.

댓글 수: 7

Bill White
Bill White 2024년 1월 29일
편집: Bill White 2024년 1월 29일
seems to work a treat - thanks a lot!
As an extention - is it possible to save a matlab figure rather than a single image?
For example, if I have a Figure of subplots of several frames; is it possible to automatically save that Figure (as one would do if they went to Save As from the Figure menu)
regards
Voss
Voss 2024년 1월 29일
You're welcome!
Bill White
Bill White 2024년 1월 29일
sorry to bother you - but I added a caveat about saving an entire Figure (i.e. a subplot with titles etc). Is that possible?
Bill White
Bill White 2024년 1월 29일
thanks again!
Voss
Voss 2024년 1월 29일
You're welcome!
On second thought, exportgraphics might be more like what you're after.
Bill White
Bill White 2024년 1월 29일
thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2024년 1월 29일

댓글:

2024년 1월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by