Can someone please help me create a code in MATLAB that can achieve the followin
ID: 2268215 • Letter: C
Question
Can someone please help me create a code in MATLAB that can achieve the following:
Write a computer program capable of performing the four arithmetic operations between two images. In addition to multiplying two images, your multiplication function must be able to handle multiplication of an image by a constant. The operations can be demonstrated using the following images:
1.- Addition Fig0241(a)(einstein low contrast), Fig0241(c)(einstein high contrast)
1a)low contrast:
1c) High Contrast
2. - Subtraction Fig0228(a)(angiography_mask_image), Fig0228(b)(angiography_live_ image)
2a)mask image
2b)live image
3.- Multiplication Fig0230(a)(dental_xray), Fig0230(b)(dental_xray_mask)
3a)dental_xray
4.- Division Fig0229(a)(tungsten_filament_shaded), Fig0229(b)(tungsten_sensor_shading)
4a)tungsten_filament_shaded
4b)tungesten_sensor_shading
thank you so much
Explanation / Answer
clc;
clear all;
close all;
i1=imread('1.png');
i2=imread('2.png');
%for addition
i=i1+i2;
figure;
imshow(i);
title('addition image');
j1=imread('3.png');
j2=imread('4.png');
j=j1-j2;
figure;
imshow(j);
title('subtraction');
k1=imread('5.png');
% k1=rgb2gray(k1);
k2=imread('6.png');
% k2=transpose(k2);
% k=immultiply(k1,k2);
k = bsxfun( @times, k1, k2 );%as the images are different size
figure;
imshow(k);
title('multiplication');
l1=imread('7.png');
l2=imread('8.png');
l=imdivide(l1,l2);
figure;
imshow(l);
%%%%%for constant multiplication
k=k1.*constant;
l=l1./constant;