Draw Switzerland Flag Using Matlab Last Updated : 23 Jul, 2024 Comments Improve Suggest changes Like Article Like Report 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. RGB image representation: The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. Consider an RGB image array ‘I’ then,I(:, :, 1) represents the Red colour plane of the RGB imageI(:, :, 2) represents the Green colour plane of the RGB imageI(:, :, 3) represents the Blue colour plane of the RGB imageApproach:Make a 3 order zero matrix of dimensions 30 X 50 X 3. 30 denotes the number of pixels for rows, 50 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)Make the vertical white bar.Below is the implementation: Matlab % matlab code to draw Switzerland flag I = zeros(30, 50, 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(5:25, 22:28, 1:3) = 255; %white column I(12:18, 10:40, 1:3) = 255; % show the image formed imshow(I); Output: Comment More infoAdvertise with us A Akshita33Patwal Follow Improve Similar Reads Interview Preparation Interview Preparation For Software Developers Must Coding Questions - Company-wise Must Do Coding Questions - Topic-wise Company-wise Practice Problems Company Preparation Competitive Programming Software Design-Patterns Company-wise Interview Experience Experienced - Interview Experiences Internship - Interview Experiences Practice @Geeksforgeeks Problem of the Day Topic-wise Practice Difficulty Level - School Difficulty Level - Basic Difficulty Level - Easy Difficulty Level - Medium Difficulty Level - Hard Leaderboard !! Explore More... Data Structures Arrays Linked List Stack Queue Binary Tree Binary Search Tree Heap Hashing Graph Advance Data Structures Matrix String All Data Structures Algorithms Analysis of Algorithms Searching Algorithms Sorting Algorithms Pattern Searching Geometric Algorithms Mathematical Algorithms Randomized Algorithms Greedy Algorithms Dynamic Programming Divide & Conquer Backtracking Branch & Bound All Algorithms Programming Languages C C++ Java Python C# Go Lang SQL PHP Scala Perl Kotlin Web Technologies HTML CSS JavaScript Bootstrap Tailwind CSS AngularJS ReactJS jQuery NodeJS PHP Web Design Web Browser File Formats Computer Science Subjects Operating Systems DBMS Computer Network Computer Organization & Architecture TOC Compiler Design Digital Elec. & Logic Design Software Engineering Engineering Mathematics Data Science & ML Complete Data Science Course Data Science Tutorial Machine Learning Tutorial Deep Learning Tutorial NLP Tutorial Machine Learning Projects Data Analysis Tutorial Tutorial Library Python Tutorial Django Tutorial Pandas Tutorial Kivy Tutorial Tkinter Tutorial OpenCV Tutorial Selenium Tutorial GATE CS GATE CS Notes Gate Corner Previous Year GATE Papers Last Minute Notes (LMNs) Important Topic For GATE CS GATE Course Previous Year Paper: CS exams Like