A colored image can be represented as a 3 order matrix. The first order is for the rows, the second order is for the columns and the third order is for specifying the color of the corresponding pixel. Here we use the RGB color format, so the third order will take 3 values of Red, Green ans Blue respectively. The values of the rows and columns depends on the size of the image.
Prerequisite : RGB image representation
- Make a 3 order zero matrix of dimensions 300X500X3. 300 denotes the number of pixels for rows, 500 denotes number of pixels for columns and 3 denotes the color coding in RGB format. The image starts completely black because for all the pixels the color code is (0, 0, 0).
- Paint the horizontal bar between rows 1 to 100, and between columns 101 to 500 green. The color code of green in Kuwait’s flag is (0, 122, 61).
- Paint the horizontal bar between rows 101 to 200, and between columns 101 to 500 white. The color code of white is (255, 255, 255).
- Paint the horizontal bar between rows 201 to 300, and between columns 101 to 500 red. The color code of red in Kuwait’s flag is (206, 17, 38)
- At this point we have an image which looks like this:
Now we have to draw 2 triangles.
- For the upper green triangle. In the matrix with rows from 1 to 100, and columns from 1 to 100, paint the upper right triangle green.
- For the lower red triangle. In the matrix with rows from 201 to 300, and columns from 1 to 100, paint the lower right triangle red.
Below is the implementation :
- Draw Austria flag using Matlab
- Draw Thailand Flag Using MATLAB
- Draw Bangladesh Flag Using Matlab
- Draw Switzerland Flag Using Matlab
- Draw Sweden Flag using matlab
- How to draw Japan flag using MATLAB
- Draw Sudan Flag using MATLAB
- Draw Indian Flag using matlab
- Draw Seychelles Flag using MATLAB
- MATLAB | RGB image representation
- Matlab | Erosion of an Image
- Matlab | Dilation of an Image
- Image Complement in Matlab
- Image Resizing in Matlab
- Reverse Video in Matlab
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.