automatic file saving script

5 views (last 30 days)
Jackie Burris
Jackie Burris on 27 Oct 2018
Commented: Stephen23 on 27 Oct 2018
Hello, I am brand new to MATLAB (this is my first project). I managed to write the script to bring two files (JPG) into MatLab and run some basic processes.
Each newly converted file I want to automatically save as an image file and automatically save the generated surface plot to the current folder (TEST2_MATLAB). I plan to run many many files (TEST2_MATLAB, to TESTn_MATLAB) through these steps and really would like to minimize the tedium and human error from the repetition of having to individually save each file. I have attached a screenshot of what I would like the final 'current folder' to resemble. Files with the prefix M_ is a coverted file created and saved from 'imshow'. Files with M_P_ are the surface plots for each converted file. How can I automate this? When I try to do this all I can get is the file save window I would still need to select the file type and rename the file and select the location. Thank you THIS IS THE SCRIPT;
% Bring in photo file and rename%
PHOTO=imread('digitalPhoto.JPG');
%Bring in digital file and rename. File parameters 30x30x3%
FILE=imread('digitalfile.jpg');
%Resize the photo to match the original digital file dimensions%
% 30 = number of columns you have specfied based on original digital file%
PHOTORESIZE=imresize(PHOTO, [30 NaN]);
%create surface model%
surf(PHOTORESIZE);
%convert the true color image to gray scale%
photogray=rgb2gray(PHOTORESIZE);
imshow(photogray);
%create surface model%
surf(photogray)
%convert the true color image to gray scale%
filegray=rgb2gray(FILE);
imshow(filegray);
%create surface model%
surf(filegray);
%difference between file gray when photogray is deducted%
imageDiffFP=abs(filegray-photogray);
imshow(imageDiffFP);
%create surface model%
surf(imageDiffFP)
%difference between photogray when filegray is deducted%
imageDiffPF=abs(photogray-filegray);
imshow(imageDiffPF);
%create surface model%
surf(imageDiffPF);
%save coverted files as plots jpgs surface plots NOT SURE HOW %
%save workspace after running whole script %
%THIS GOES LAST%
save workspace

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!