arithmetic.m
来自「matlab关于对图像进行卷积等操作的一段程序」· M 代码 · 共 37 行
M
37 行
%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 + =
减小字号Ctrl + -
显示快捷键?