Open In App

Draw Austria flag using Matlab

Last Updated : 24 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite: RGB image representation 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 depending on the size of the image. Approach:

  • Make a 3 order zero matrix of dimensions 300 X 600 X 3. 300 denotes the number of pixels for rows, 500 denotes number of pixels for columns and 3 denotes the color coding in RGB format.
  • Paint the complete image in red. RGB code for red is (255, 0, 0)
  • Make the horizontal white bar. RGB code for white is (255, 255, 255).

Below is the implementation: 

Matlab




I = zeros(300, 600, 3);
% here image is of class ‘uint8’, the range of values
% that each colour component can have is [0 – 255]
I = uint8(I);
%painting the whole image red
I(:, :, 1) = 255;
%white bar
I(101:200, :, 1:3) = 255;
% show the image formed
imshow(I);


Output:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads