Prerequisite: RGB Image Representation
MATLAB, also called Matrix Laboratory, is a numerical computing environment and a platform for programming languages. It was designed and developed by MathWorks. MATLAB is a framework that allows us to perform matrix manipulations, implementing algorithms, plotting functions and data, creating user-interfaces and interfacing with programs that are written in different programming languages i.e. C, C++, python, java etc..
How to draw a colored image in MATLAB ?
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 and Blue respectively. The values of the rows and columns depend on the size of the image.
Approach to draw the flag of japan:
- Make a zero matrix of 3 order that has dimensions (300, 500, 3) where 300 denotes the number of pixels for rows, 600 denotes the number of rows and 3 denotes the color coding in RGB format.
- Color the whole matrix in white color first. RGB for red color is (255, 255, 255).
I(:, :, :)=255;
- Apply loop on rows and columns and implement the equation of the circle such that we get a circle in the center of the flag and color it crimson glory using RGB format.
Equation of circle:
((x-h)^2 - (y-k)^2)=r^2
where (h, k) are the centers, (x, y) are co-ordinates of x-axis and y-axis and is the radius of the circle.
rgb format for crimson glory color is (188, 0, 45).
Below is the code:
- Draw Bangladesh Flag Using Matlab
- Draw Sudan Flag using MATLAB
- Draw Kuwait Flag using MATLAB
- Draw Thailand Flag Using MATLAB
- Draw Indian Flag using matlab
- Draw Austria flag using Matlab
- Draw Seychelles Flag using MATLAB
- Draw Switzerland Flag Using Matlab
- Draw Sweden Flag using matlab
- Reverse Video in Matlab
- Image Complement in Matlab
- MATLAB | RGB image representation
- Matlab | Dilation of an Image
- Image Resizing in Matlab
- Matlab | Erosion of an Image
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.