Open a file in a program or application and save in another format
古いコメントを表示
How can a file (i.e. a .jpg image) be opened in a program (i.e. MS. Paint) and saved in a different format (i.e., TIF)?
I'd also appreciate hints to perform more tasks such as resizing the image or using other functions of the program in which the file is opened.
2 件のコメント
Geoff Hayes
2022 年 12 月 23 日
@Vahid Atashbari - please clarify how your question relates to MATLAB. Why do you want the file to be opened in MS Paint? Are you also asking how to resize (or do whatever) the image using MS Paint too?
Vahid Atashbari
2023 年 1 月 8 日
採用された回答
その他の回答 (1 件)
Sulaymon Eshkabilov
2022 年 12 月 23 日
1 投票
You can try with the following functions to save image data - saveas() in an image file and open in MS applications using winopen():
(1) To save your image data displayed in a Figure window using: saveas(gcf, 'IMAGE', 'jpg')
(2) To open the file from MATLAB: winopen('IMAGE.jpg')
3 件のコメント
Vahid Atashbari
2023 年 1 月 8 日
DGM
2023 年 1 月 8 日
Save images using imwrite() instead of figure capture.
imwrite(myimagevariable,'outputfile.png')
Using figure capture will usually result in the image being crudely resized with nearest-neighbor interpolation, some amount of excess white padding added, and the image potentially changing type (e.g. a binarized, indexed, or grayscale image being converted to RGB). It's destructive, poorly-controlled, and typically unnecessary.
JPG is also destructive and often unnecessary. Using JPG as an intermediate step between the workspace and a (typically) lossless format like TIFF largely defeats the purpose of using a lossless format.
For the specific case of MSPaint, I imagine most of the work that can hypothetically be done programmatically in Paint can also just be done in MATLAB.
For the general case of controlling other applications, I don't know if an arbitrary application supports desired operations through a command line interface or if there is some API to do it. That would require specifics. If you can write an external script to do it, then there you can always run that script via MATLAB.
Vahid Atashbari
2023 年 1 月 27 日
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!