Basic Operations on Images | Making Vehicles and Robots See: Getting Started with Perception for Students - MATLAB
Video Player is loading.
Current Time 0:00
Duration 7:39
Loaded: 2.16%
Stream Type LIVE
Remaining Time 7:39
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 7:39

    Basic Operations on Images | Making Vehicles and Robots See: Getting Started with Perception for Students

    From the series: Making Vehicles and Robots See: Getting Started with Perception for Students

    Learn how to work with images in MATLAB® such as reading and displaying images. Explore basic operations like resizing, cropping, and rotating. Understand how to select the correct color space for your task and how to enhance image quality. At the end of this video, perform an exercise using basic operations on images in Simulink®.

    Published: 27 Jul 2021

    While designing your autonomous systems, you typically have a requirement to see your environment. It could be an underwater vehicle that's going through obstacles or a student car maneuvering through cones or a robot picking up and placing an object. You see the environment.

    And depending on what you observe, your vehicle or robot will perform the next set of tasks. That is why you have perception as an integral part of your autonomous systems. They help your vehicle see the environment using vision sensors.

    In these videos, we will try and give you some helpful tips that you could use to get started with perception-related tasks for your student projects. In today's video, you will get an introduction to working with images in MATLAB. You will first read and display an image.

    You will then resize and crop image to get a region of interest, change the image colors spaces to find the one that suits our project path the best, and eventually try and understand on how you can enhance your image. We strongly recommend you to complete the image processing onramp to understand the basic details about working with an image.

    Great, so let's get started. For all of us who are new to images, an image is nothing but a 2D matrix of pixels. The first task is to get this image into MATLAB. You can do this using the imread command and specify the name of the file that distributed.

    Let us visualize this RGB image. We can use the imshow command to view the image output. Then we read the image in MATLAB. We see that we get a variable with a dimension of 1080 by 1920 by 3.

    What does this mean? This means that our image has three cascaded matrices of 1080 cross 1920 dimension. And what do each of these three metric slices look like? First is red, second is green, and the third is blue. This is because this image was captured using True Color RGB camera. This is the RGB color space.

    But what if you're working with the IP camera that is transmitting a video over narrow channels and sends the image information in a different color space? Let's say, YCbCr. It will still be three channels, but each channel would represent something a little different.

    The first will be the luma component, which is the brightness of the image. The second will be the blue-difference. And the third will be the red-difference color information.

    So the next question that you may have is, when do we use rich color space? The answer is, well, it depends on the type of image that you're working with and the nature of your interest region in that image. The best way to find out is to try different color spaces and find that color space that will help you get the highest probability of success to find your region of interest.

    Now, let's say for your task, you just need the intensity information. For this, all we need to do is just use the y channel from the YCbCr color space, which is grayscale image. Just by working with the necessary space that you want will help you save computational power.

    For example, these scale images are sufficient for many tasks. Hence, there's no need to use more complicated and harder process color images. Now, let's say you have an image, but it is too large for you to use. Or it could also be that let's say you have a certain pre-trained convolutional neural network. Let's say like, AlexNet.

    And you have to have an image input size of 227-by-227. When you come across such situations, you can resize the image using the imresize function. You can resize it to a specific percentage of the image size or maybe as a specific dimension.

    Now, let's say you are interested in working only on a specific part of the image. From this image, you just need the view of the road and eliminate the part that's the driver in the car. Instead of using this specific part of the image, if you use an entire image, you will be using more computational power. For situations like these, you can separate the part of the known area by cropping your region of interest. We'll use to improve function to crop only the part that we need.

    Now let's say we have the cropped image, but you wish to align the image at a specific angle. For example, like this water level, you want to align it correctly. What you can do here is rotate the image by a different angle. So you can use the iamrotate function to rotate the front view of the car by a specific degree.

    After understanding some basics of working with images, let's dive into a problem. Let's say you are at an event where your autonomous racing car competition is held. You expected it to be a clear sky, but it turns out that it's pretty cloudy that day. How do you pre-process such kind of data?

    This is where image filtering and enhancement helps. It makes it easier to identify key features of an image by removing noise, sharpening, or adjusting contrast. You can use the image viewer app to interactively control the contrast.

    Ultimately, you can also use histogram equalization to have the intensities better distributed on the histogram. You can use the histeq function and provide the name of your grayscale image. For more details on basic operations and images, do not forget to complete the image processing onramp.

    A lot of you who are watching this video are probably working on a planned model, which could be, let's say, your car your, robot, or your drone in Simulink. And it has a specific sensor to fetch images. What we will do now is give you a small exercise and learn about using image processing in Simulink.

    However, if you're not familiar with Simulink and want to learn more about it, please check the Simulink Onramp. For exercise, we have an image in YCbCr color space. Use the grayscale image from this image input, rotate the grayscale image, and resize it using Simulink.

    Now coming to the key takeaways-- first, MATLAB provides an extensive set of libraries of built-in image processing algorithms. MATLAB help documentation and related resources such as examples, interactive courses, and videos can help you get started quickly. And you can implement previous image processing algorithms in Simulink.

    And while you're working through the video and the exercises, if you come across any questions, feel free to reach out to us at roboticsarena@mathworks.com. We'll see you in the next video.

    Related Information

    Up Next:

    View full series (5 Videos)

    View more related videos