Exploring digital images: Interactive design (Part 2)


In the previous blog, we have seen the use of msgbox to have interaction with user. Let us know, use another interactive tool, called the menu to have more interaction with user.

Octave code:

clc;
clear all;
input_image = imread("ubuntu.jpg");
[height width channels] = size(input_image);
figure, imshow(input_image); title("Input Image");
if channels == 3
  msgbox("Input image is a color image");
  choice = menu("Do you want to convert into grayscale", "Yes", "No");
  if choice == 1
   grayscale_image = rgb2gray(input_image);
   figure, imshow(grayscale_image); title("Grayscale Image");
   else
   msgbox("Exiting execution prcoess");
   close all;
  end
 else
 disp("Input image is grayscale image")
  imshow(input_image);
end

Output:
Octave code

Interactive msgbox

Interactive menu option

Output of above code
Explanation:
Menu is a interactive dialog box that shows multiple option for user to choose.
-- CHOICE = menu (TITLE, OPT1, ...)
-- CHOICE = menu (TITLE, {OPT1, OPT2...})
     Display a menu with heading TITLE and options OPT1,OPT2 ..., and wait
     for user input.

Comments

Post a Comment

Popular posts from this blog

Washing Machine: An example of mechatronics system

Proximity sensors

Piezoelectric Pressure Sensor