Table of Contents (click for easy navigation)
- What is MATLAB Print?
- Introduction to MATLAB Print
- MATLAB Print Basics: Brief Tutorial in MATLAB
- Example: Bar Chart Manipulation
- Example Two: Copy Figure to Clipboard
- Example Three: Saving as a .png
What is MATLAB Print?
After all the mental equity used to generate your system models and their progression…next is the presentation of your handiwork. Image is EVERYTHING. MATLAB as a software, has the ability to generate a myriad of images once the relevant data has been entered either into the MATLAB or Simulink environments. Once the relevant generated output is presented, you the user, have the ability to manipulate the images to suit your visualization needs. Since the images generated may not all be the exact size we want, a few resizing tweaks will have to be done.
MATLAB has a very intuitive system that facilitates the image resize for all your printing needs. Because of the matrix-based nature of the MATLAB system algorithms, image sizing is not a challenge to the system. Previous lessons on transposition of matrices, identified how the background algorithms can manipulate your data to generate the scaled output that you desire. Systems such as Microsoft Word, Microsoft Powerpoint and other higher level user-friendly software actually are less efficient with respect to image sizing because of their scaling mechanism. What they simply do is stretch the image dimensions, but diminish the image quality with the changes. With tools such as MATLAB scaling is a possibility, and the appropriate resolution will be adjusted in order to best suit the desired size. With the scaling capabilities of MATLAB, the image quality is preserved. This tutorial is based on the R2018b version of the software.
Introduction to MATLAB Print
MATLAB as a system has a myriad of ways to manipulate output. Code alert…there are at least twelve ways to manipulate your images once you have generated them. For the purposes of this tutorial, all the options will be defined, and a couple main functions that the average user needs will be demonstrated. If you’re a more sophisticated user… you’ll have access to the codes you’ll need for the further stages of your image processing. If you like to keep things simple, you can focus on the main syntaxes.
cdata = print('-RGBImage');
Print Options Defined
MATLAB is code heavy on the print options, let us take the time to define what
each of the options mean, before we delve into the demonstrations.
) is an option that saves your
current figure you’ve generated according to the desired image format such as
.jpg, .png. The system will automatically assign a format if the user does not
) is an extension of print formats.
If there are additional formatting options available for certain print
extensions, you can use this option to define what changes you want to make.
print as an option, is the option selected when your system is connected to a default printer. The file will automatically print your displayed image, unless otherwise specified.
) is an option for choosing the printer
of choice. Most MATLAB users operate in a work or school setting, which
contains a network of printers in the workspace. Depending on where you are,
and your imaging needs (larger images for corporate presentations for instance,
or smaller images for your own project uses) this options allows you to
determine where you send your files, and what size the output should be.
) is a driver choice. Many images
generated by MATLAB are color intensive. The driver option facilitates the
ability to toggle between the color saving (black and white) or color printing.
print('-clipboard',clipboardformat) is the copy option in MATLAB. With
the images stored in the clipboard, the user has the ability to transfer the
image to other applications such as Word, Excel or other open source software
such as Google Docs.
a resizing option that enables the image to fit the screen. With imaging sizing
options available with this option the image quality will be preserved with the
system allowances to respect the figures aspect ratio. This is one of the
sophisticated options that can be fused with other syntaxes in the list.
the user to specify the print resolution. Resolutions can be specified as
character vectors or as strings based on the user’s desires.
) This option allows the user to choose a
renderer. A renderer is the fusion of software and hardware that facilitates
image processings. It facilitates the system’s ability to display, print or
export a figure.
a clean image output. Typically user images look like the following:
The image is inclusive of user interface controls. Using this option allows a clean image to be printed, exclusive of the GUI influencer controls.
) provides the user with the ability
to print a pre-specified figure based on its figure number. This option is
available according to both MATLAB and Simulink environments.
is an option for analyzing the system properties of a current image that is
displayed. This displayed information is the background resolution details
needed to identify the color density of an image. Fusing with other syntax
properties is a possibility for this option. The only option that is excluded
is a Simulink block diagram.
With the theory outlined above, let us now look at the various possibilities for MATLAB print specifications in the MATLAB R2018b user environment. A fresh command page is open below. For the purposes of this tutorial, we will focus on the Command Window, the Workspace output, and the Current folder.The critical windows for the exercise are the command window to the right hand side of the screen. This is where the relevant code for the program will be entered. To the bottom left will be the workspace, is where the answers will be displayed.
With our Command Center ready, let us start manipulating some images! For those color scientists in our midst, this is where the fun begins. With a sample image, there are various manipulations that we can attempt. As with all science based activities…let’s explore by trial and error!! From the MATLAB workbook, let us work with the following example. Starting with the bar chart bar(1:10) we will carry the image through a series of iterations. Without any further ado (after all that code) let’s jump into it!
Example: Bar Chart Manipulation
Print Paper Copy of Figure
Objective: Create a bar chart and print it to your system default printer. If you do not specify the figure to print, then
Displayed below is the image in the MATLAB GUI. The bar chart generated is the image that we will manipulate.
The next step is to enter the print code:
The following printer prompt, will be displayed. Depending on your operating system and connectivity, there will be a slight difference. The prompt is asking the user what printer option the MATLAB system should send the image to. Once the option is chosen, the file will be sent to the relevant printer and be printed.
Example Two: Copy Figure to Clipboard
Create a plot and copy it to the system clipboard.
Using the image above, the MATLAB system facilitates the copying of the image onto the system clipboard, and then you can paste the copied plot into other applications. These other applications include word processors such as Microsoft Word or Google Docs. Entering the code into MATLAB saves the image to the clip board. Opening a fresh Microsoft word document, and entering Ctrl +V or the paste option generates the following image.
Save Figure as Image File
Example Three: Saving as a .png
Objective: Create a plot and save it as a PNG image file.
This option generates a .png file that you can import into the MATLAB system. When you enter the code, you’ll see the .png option of the file in the Current Folder of the MATLAB GUI. This is the smaller window in the top right of the file. Double clicking on the file created, generates an import prompt into MATLAB.
Pressing Finish in the prompt above will import the file into the MATLAB system. As you can see, the possibilities of image manipulation in the MATLAB system are numerous. With a little trial and error, you can work your way down the list, and allow yourself to achieve your image presentation needs.
Image manipulation in MATLAB is a straightforward process, once you are aware of the different syntax codes that are available to you. With an inbuilt matrix base, whether you’re a color scientist in need of image resizing practice, or an engineer wanting to print a large scale visual of your population balance model for a major conference presentation, the possibilities are endless. With advances and sophisticated options, compared to regular word processors, MATLAB is the ideal environment for your image re-sizing needs, while at the same time preserving your image quality.
Tandose Sambo is a Chemical Process Engineer, with a focus on improving process efficiency via operational improvements. Six-Sigma certified, and with a Design-focus and Data Analytics interest, she is a driven growing entrepreneur, with the intention to optimize industrial and business process operations. Her interests include sharing time with family and travelling.