Draw Bangladesh Flag Using Matlab
Last Updated :
24 Mar, 2023
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 400 X 3. 300 denotes the number of pixels for rows, 400 denotes number of pixels for columns and 3 denotes the color coding in RGB format.
- Paint the complete image in bottle green.
- Using the equation of circle paint the circle bright red. The 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.
Below is the implementation:
Matlab
I=zeros(300, 400, 3);
I=uint8(I);
I(:, :, 1)=0;
I(:, :, 2)=106;
I(:, :, 3)=78;
for i=100:200
for j=150:250
if round(sqrt((i-150)^2+(j-200)^2)<50)
I(i, j, 1)=244;
I(i, j, 2)=42;
I(i, j, 3)=65;
end
end
end
imshow(I);
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...