Kahibaro
Discord Login Register

Introduction to Signal and Image Handling

Overview

This chapter gives you a first look at how MATLAB can handle signals and images. The goal is not to make you an expert in signal processing or image processing, but to make you comfortable with the basic ideas and with how MATLAB represents and manipulates these types of data.

You will see that signals and images are stored as ordinary MATLAB arrays. The difference lies in how you interpret these arrays and which functions you use with them. Later chapters will focus on specific tasks like filtering signals or transforming images. Here you will build the mental picture that connects those tasks to MATLAB data.

What Are Signals in MATLAB

A signal is any quantity that varies over some independent variable. In many beginner examples the independent variable is time, and the signal is something like sound, temperature, or voltage measured over time. Mathematically, you can think of a signal as a function, for example $x(t)$.

In MATLAB, a simple discrete-time signal is usually represented by a vector. Each element of the vector is the value of the signal at one sample time. If you name your signal x, you can imagine that x(1) is the value at the first sample, x(2) at the second sample, and so on.

A one channel signal, for example a mono audio track, is usually a column or row vector. A multi channel signal, for example stereo audio, is often stored in a matrix, where each column corresponds to a channel and each row corresponds to a time sample.

You interpret the index of the vector as sample number. If the sampling frequency of your signal is $F_s$ samples per second, then sample $n$ corresponds to time
$$
t_n = \frac{n - 1}{F_s}.
$$
You will often see code that constructs a time vector t so that you can plot x against actual time values. This is not required by MATLAB, but it helps you understand your data visually.

What Are Images in MATLAB

An image is also a special type of signal. Instead of depending on one variable like time, it depends on two spatial variables, which you can call $x$ and $y$ or row and column. A grayscale image can be viewed as a two dimensional array, where each element is the brightness at that pixel position.

In MATLAB, a typical grayscale image is stored as a 2D matrix. If the image size is $M$ by $N$, then you can think of it as having $M$ rows and $N$ columns of pixels. The value in element (i, j) contains the intensity of the pixel at row i and column j.

Color images usually have three color channels, commonly red, green, and blue. In MATLAB they are stored as a 3D array of size $M$ by $N$ by 3. The first two dimensions are the pixel positions, and the third dimension indexes the color channel. For example, img(:,:,1) represents the red channel, img(:,:,2) the green channel, and img(:,:,3) the blue channel.

The values inside an image array often represent intensity or color components on a scale. For example, you may see values between 0 and 255 stored as integers, or values between 0 and 1 stored as floating point numbers. The scale and data type determine how MATLAB displays and processes the image.

Array View of Signals and Images

The most important idea in this introductory chapter is that at the MATLAB level, signals and images are just arrays.

A one dimensional signal is a vector. A multi channel signal is usually a matrix with one dimension for time and one for channel. A grayscale image is a two dimensional matrix. A color image is a three dimensional array, with two spatial dimensions and one channel dimension.

This means that many operations you learned for vectors, matrices, and arrays apply directly to signals and images. You can index individual samples or pixels using parentheses, slice out ranges, and apply arithmetic or built in functions over the array.

For example, if you want to darken an image you are simply scaling its array values by a factor less than 1. If you want to increase the volume of a sound signal you scale the vector containing the samples. If you want to swap color channels in an image you rearrange the third dimension of the array.

This unified view simplifies learning. Instead of thinking that signals and images require completely different programming, you can remember that they are special cases of arrays with certain shapes and interpretations.

Working with Sampled Data

In many signal and image tasks, the data is sampled. This means that a continuous real world quantity has been measured at discrete points. MATLAB does not store continuous waveforms or continuous images. It stores finite collections of samples.

For one dimensional signals, the distance between sample points is related to the sampling frequency. If the sampling frequency is $F_s$, then the spacing between samples in time is $1 / F_s$. In MATLAB code you will usually keep track of this sampling frequency in a separate variable. The vector of signal values itself does not contain the sampling frequency.

For images, the sampling grid is determined by the number of rows and columns. Each pixel corresponds to an area of the scene. You can think of the pixel indices as sampled positions. Just as with signals, you often need separate information about the physical size or resolution of the image if that matters for your application. The matrix itself only contains pixel values, not physical units.

When you use MATLAB to generate signals or images artificially, you will often construct both the sample positions and the data. You may build a time vector and then compute a signal as a function of time, or build grid coordinates for an image and then compute intensity values. This consistent approach helps bridge the gap between mathematical definitions and array-based code.

Toolboxes for Signals and Images

MATLAB by itself provides basic functions that can load, display, and manipulate signals and images at a simple level. For more advanced processing, MathWorks provides specialized toolboxes.

Signal processing tasks such as digital filters, spectral analysis, and resampling are often supported by the Signal Processing Toolbox. Audio related functions may be provided by specific audio toolboxes. These toolboxes introduce higher level functions that work directly on signal vectors or on special objects that store sampled data.

Image processing tasks such as advanced filtering, segmentation, and geometric transformation are often supported by the Image Processing Toolbox. With this toolbox you gain access to functions that understand image arrays, color spaces, and neighborhood operations.

As a beginner, you do not need to know all the toolbox details. It is enough to know that signals and images are represented as arrays, and that specialized toolboxes build on this representation to provide application specific functions. When reading documentation you will often see which toolbox a function belongs to.

Visualizing Signals and Images

A central reason to use MATLAB for signals and images is its visualization capabilities. You can look at your data in many ways that help you understand it.

For one dimensional signals, the most common visualization is a plot of sample values versus time. You take your signal vector and use it with a plotting function to see the waveform. If you have more than one channel you may plot each channel separately or on the same axes.

For images, you typically display the image array as an image on the screen. The matrix values are mapped to grayscale or color values, and you see the result as a picture. Color images stored as 3D arrays can be displayed directly, and MATLAB interprets the last dimension as color channels.

These visualizations do not change the underlying arrays. They are views of the same numerical data. Understanding this distinction is helpful, because any numeric operation you apply to the signal or image is reflected in what you see when you update the display.

Relationship Between Signals, Images, and Time

You will often encounter tasks where signals and images interact. For example, video is a sequence of images over time. In MATLAB this can be represented as a 4D array, with two spatial dimensions, one color channel dimension, and one time dimension, or organized in other ways such as a sequence of image frames.

Similarly, audio and image data can be processed together, for example in multimedia applications. MATLAB treats all of these as arrays of numbers with certain shapes and sometimes with associated metadata, such as sampling rate or frame rate.

This general principle is that signals add a notion of time or sequence to your data, while images add spatial arrangement. MATLAB lets you represent both within the same array framework, by using extra dimensions or by structuring your data appropriately.

Where This Chapter Fits

This introductory chapter is a bridge between general MATLAB array handling and the more specific tasks of signal and image work. Later chapters in this section will show you how basic signal representations are built and manipulated, how filters and simple transforms are applied, and how images are read, displayed, and transformed.

Each of those later topics will rely on the ideas introduced here: a signal is a 1D or 2D array interpreted over a sampling grid, and an image is a 2D or 3D array interpreted as spatial samples and possibly color channels. Once you are comfortable viewing signals and images as arrays with structure, the MATLAB functions you encounter will feel more familiar.

Signals and images in MATLAB are just numeric arrays with different shapes and interpretations. A 1D signal is usually a vector, a multi channel signal is a matrix, a grayscale image is a 2D matrix, and a color image is typically a 3D array. MATLAB stores sampled data, not continuous functions, and advanced processing is provided by specialized toolboxes that build on these basic array representations.

Views: 3

Comments

Please login to add a comment.

Don't have an account? Register now!