📄 arithmetic.m
字号:
%Question No:1
%Write a MATLAB function which performs the four arithmetic operations
%between two images.
function arithmetic(x,y)
a=imread(x);
b=imread(y);
a=im2double(a);
b=im2double(b);
choice=input('1: Addition \n2: Subtraction \n3: Multiplication \n4: Division \n Enter the choice : ');
switch choice
case 1
c=a+b;
subplot(1,3,1),imshow(a),title('Image 1');
subplot(1,3,2),imshow(b),title('Image 2');
subplot(1,3,3),imshow(c),title('Image After Addition');
case 2
c=a-b;
subplot(1,3,1),imshow(a),title('Image 1');
subplot(1,3,2),imshow(b),title('Image 2');
subplot(1,3,3),imshow(c),title('Image After Subtraction');
case 3
c=a.*b;
subplot(1,3,1),imshow(a),title('Image 1');
subplot(1,3,2),imshow(b),title('Image 2');
subplot(1,3,3),imshow(c),title('Image After Multiplication');
case 4
c=a./b;
subplot(1,3,1),imshow(a),title('Image 1');
subplot(1,3,2),imshow(b),title('Image 2');
subplot(1,3,3),imshow(c),title('Image After Division');
otherwise
error('Wrong Choice');
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -