Open a file in a program or application and save in another format
Ältere Kommentare anzeigen
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 Kommentare
Geoff Hayes
am 23 Dez. 2022
@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
am 8 Jan. 2023
Akzeptierte Antwort
Weitere Antworten (1)
Sulaymon Eshkabilov
am 23 Dez. 2022
1 Stimme
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 Kommentare
Vahid Atashbari
am 8 Jan. 2023
DGM
am 8 Jan. 2023
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
am 27 Jan. 2023
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!