Question

In: Electrical Engineering

1- Write a Matlab program to perform image resizing, image rotation to 90 degrees, conversion to...

1- Write a Matlab program to perform image resizing, image rotation to 90 degrees, conversion to binary and gray scale, Image segmentation and extraction, draw and find the region of interest with a circle, Plot bounding box, Region extraction and histogram.

2- Write a MATLAB program to Design a GUI calculator which is as shown in below figure 1. Add tool bar options to the GUI calculator and Highlight specific codes written in program and signify the steps followed.

Solutions

Expert Solution

a=imread('peppers.png');

[rows,columns,layers]=size(a)

i=1;j=1;k=1;

c=zeros(rows/2,columns/2,layers);

c=uint8(c);

figure

imshow(a) % Display BEFORE casting to double.

a = double(a);

for x=1:2:rows-1;

for y=1:2:columns-1;

for z=1:layers;

c(i,j,k)=1/4*(a(x,y,z)+a(x,y+1,z)+a(x+1,y,z)+a(x+1,y+1,z));

k=k+1;

end

j=j+1;

k=1;

end

i=i+1;

j=1;

k=1;

end

axis on;

figure,

imshow(c)

axis on;

matlab code for GUI calculator

% Simple calculator for understanding of GUI

function varargout = calculator_2(varargin)

% CALCULATOR_2 MATLAB code for calculator_2.fig

% CALCULATOR_2, by itself, creates a new CALCULATOR_2 or raises the existing

% singleton*.

%

% H = CALCULATOR_2 returns the handle to a new CALCULATOR_2 or the handle to

% the existing singleton*.

%

% CALCULATOR_2('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in CALCULATOR_2.M with the given input arguments.

%

% CALCULATOR_2('Property','Value',...) creates a new CALCULATOR_2 or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before calculator_2_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to calculator_2_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one

% instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help calculator_2

% Last Modified by GUIDE v2.5 26-Aug-2015 16:07:11

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @calculator_2_OpeningFcn, ...

'gui_OutputFcn', @calculator_2_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before calculator_2 is made visible.

function calculator_2_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no textoutput args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to calculator_2 (see VARARGIN)

% Choose default command line textoutput for calculator_2

handles.textoutput = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes calculator_2 wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = calculator_2_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning textoutput args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line textoutput from handles structure

varargout{1} = handles.textoutput;

% --- Executes on button press in minus.

function minus_Callback(hObject, eventdata, handles)

% hObject handle to minus (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'-');

set(handles.input,'String',str);

% --- Executes on button press in plus.

function plus_Callback(hObject, eventdata, handles)

% hObject handle to plus (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'+');

set(handles.input,'String',str);

% --- Executes on button press in division.

function division_Callback(hObject, eventdata, handles)

% hObject handle to division (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'/');

set(handles.input,'String',str);

% --- Executes on button press in multiplication.

function multiplication_Callback(hObject, eventdata, handles)

% hObject handle to multiplication (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'*');

set(handles.input,'String',str);

% --- Executes on button press in one.

function one_Callback(hObject, eventdata, handles)

% hObject handle to one (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'1');

set(handles.input,'String',str);

% --- Executes on button press in four.

function four_Callback(hObject, eventdata, handles)

% hObject handle to four (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'4');

set(handles.input,'String',str);

% --- Executes on button press in seven.

function seven_Callback(hObject, eventdata, handles)

% hObject handle to seven (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'7');

set(handles.input,'String',str);

% --- Executes on button press in two.

function two_Callback(hObject, eventdata, handles)

% hObject handle to two (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'2');

set(handles.input,'String',str);

% --- Executes on button press in three.

function three_Callback(hObject, eventdata, handles)

% hObject handle to three (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'3');

set(handles.input,'String',str);

% --- Executes on button press in five.

function five_Callback(hObject, eventdata, handles)

% hObject handle to five (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'5');

set(handles.input,'String',str);

% --- Executes on button press in six.

function six_Callback(hObject, eventdata, handles)

% hObject handle to six (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'6');

set(handles.input,'String',str);

% --- Executes on button press in eight.

function eight_Callback(hObject, eventdata, handles)

% hObject handle to eight (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'8');

set(handles.input,'String',str);

% --- Executes on button press in zero.

function zero_Callback(hObject, eventdata, handles)

% hObject handle to zero (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'0');

set(handles.input,'String',str);

% --- Executes on button press in nine.

function nine_Callback(hObject, eventdata, handles)

% hObject handle to nine (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'9');

set(handles.input,'String',str);

% --- Executes on button press in rightbracket.

function rightbracket_Callback(hObject, eventdata, handles)

% hObject handle to rightbracket (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,')');

set(handles.input,'String',str);

% --- Executes on button press in leftbracket.

function leftbracket_Callback(hObject, eventdata, handles)

% hObject handle to leftbracket (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'(');

set(handles.input,'String',str);

% --- Executes on button press in decimal.

function decimal_Callback(hObject, eventdata, handles)

% hObject handle to decimal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=strcat(str,'.');

set(handles.input,'String',str);

% --- Executes on button press in solve.

function solve_Callback(hObject, eventdata, handles)

% hObject handle to solve (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=eval(str);

set(handles.input,'String',str);

% --- Executes on button press in clear.

function clear_Callback(hObject, eventdata, handles)

% hObject handle to clear (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

set(handles.input,'String','');

% --- Executes on button press in backspace.

function backspace_Callback(hObject, eventdata, handles)

% hObject handle to backspace (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

str=get(handles.input,'String');

str=str(1:end-1);

set(handles.input,'String',str);

% --- Executes when uipanel4 is resized.

function uipanel4_ResizeFcn(hObject, eventdata, handles)

% hObject handle to uipanel4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)


Related Solutions

Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Python 3
Consider the 90 degrees rotation matrix R = [0 −1 1 0] a) Are the eigenvalues...
Consider the 90 degrees rotation matrix R = [0 −1 1 0] a) Are the eigenvalues real? b) Are the eigenvectors real? c) Find the determinant of R. d) Find the trace of R.
(Python) Write a code converting degrees in Fahrenheit to degrees Kelvin, using this conversion equation conversion...
(Python) Write a code converting degrees in Fahrenheit to degrees Kelvin, using this conversion equation conversion from degrees Fahrenheit to Celcius: ? = (? − 32) x 5/9 and then to degrees Kelvin: ? = ? + 273.15 with the following properties 1) the code should take into account that temperature in degrees Kelvin cannot be smaller than zero. In other words, your code should return 0 Kelvin as the smallest temperature for any input value of degrees Fahrenheit). 2)...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
Write a MATLAB code for importing an image and then being able to find all the...
Write a MATLAB code for importing an image and then being able to find all the coordinates that would draw that image on a plot column by column and row by row with a continuous line.
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in Celsius and the program Coverts the input to Fahrenheit using the following formula T(°F) = T(°C) × 1.8 + 32 submit the source code Design output Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else statement logic​​​​​​​​​ b)​Write a Matlab program for sensor selection of temperature, pressure, flow sensor with if-else statement logic​​​​​​​​​ ​ 2.​Assume there are four letters from an information source with probabilities as A1 0.5 A2 0.3 A3 0.1 A4 0.1 Generate the tag and find the corresponding gaps and binary values for each stage and the sequence of the symbols which are coded are a1a3a2a4a1.​​​...
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they...
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they would like to enter a real number. If yes, prompt the User for the real number. Continue to do this until the User enters “no” to the first question. After the User enters “no”, display the average of all the numbers entered. (Using Matlab) and "while" function 2.   Write a program that prompts the User for if they would like to enter a real...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT