Question

in mathlab Take two color images of same size Write the coding to perform the following...

in mathlab

  1. Take two color images of same size

Write the coding to perform the following operations

  1. Image addition
  2. Image subtraction
  3. Image multiplication
  4. Image division
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Syntax :

1)  subplot(numberOfRows, numberOfColumns, indexToBeDisplayedAt),imshow(imageName);

This will plot the image on the figure

example --> subplot(2,2,3),imshow(image);  Displaying canvas will have 2 rows, 2 columns and image will be displayed on 2nd row 1st column

2) % preceding a line comments the line. Just remove the % sign run the alternative code that has been provided in the solution.

3) img = Imread('imageName') -> Reads the image and stores the matrix by the variable name img.

Caution -> if image doesn't exist in directory/folder of the coding file, you will have to specify the relative path.

example - if folder1 contains folder2 and soccer.jpg and folder2 contains the Matlab file in which you are coding then :-

img1 = imread('../soccer.jpg');

else if folder2 contains both Matlab coding file and soccer.jpg, then :-

img2 = imread('soccer.jpg').

Matlab Code

img1 = imread('rice.png');

img2 = imread('cameraman.tif');

subplot(3,2,1),imshow(img1);

subplot(3,2,2),imshow(img2);

%Arithmetic operations work well as 16 bit operations

img1 = uint16(img1);

img2 = uint16(img2);

% % Adding images

%Using Library Function

img31 = imadd(img1,img2);

subplot(3,2,3),imshow(img31,[]);

% Self coded

img32 = img1 + img2;

% subplot(3,2,3),imshow(img32,[]);

% % Subtracting images

%Using Library Function

img41 = imsubtract(img1,img2);

subplot(3,2,4),imshow(img41,[]);

% Self coded

img42 = img1 - img2;

% subplot(3,2,4),imshow(img42,[]);

% % Multiplying images

img51 = immultiply(img1,img2);

subplot(3,2,5),imshow(img51,[]);

% % Dividing images

%Using Library Function

img61 = imdivide(img1,img2);

subplot(3,2,6),imshow(img61,[]);

% Self coded

img62 = img1./img2;

% subplot(3,2,6),imshow(img62,[]);

Output looks like this

Add a comment
Know the answer?
Add Answer to:
in mathlab Take two color images of same size Write the coding to perform the following...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write an applet program that would enter two variables in a text field and perform the...

    Write an applet program that would enter two variables in a text field and perform the following operations when calculate button is pressed. Design a friendly interface. Have buttons for all operations including exit. Addition Subtraction Multiplication Division

  • Question 1: Consider the following images: a) office_1.jpg d) saturn.png b) pears.png e) rice.png...

    To be implemented in MATLAB Question 1: Consider the following images: a) office_1.jpg d) saturn.png b) pears.png e) rice.png c) peppers.png f) onion.png Extract green channel of all the above mentioned images. Apply the following operations on each image and write down your observations. Attach your output along with observation in a word file. 1. Addition 2. Subtraction 3. Multiplication 4. Division Choose three scalars for addition, subtraction, multiplication and division. One scalar must be 14 and second scalar must...

  • Write a C++ program to take  two numbers as input from the user , compute the addition,...

    Write a C++ program to take  two numbers as input from the user , compute the addition, subtraction, multiplication and division of these numbers and display the desired formatted results.

  • Which of the following mathematical operations are and are not not allowed on two quantities with...

    Which of the following mathematical operations are and are not not allowed on two quantities with different unit dimensions? A) Allowed : Multiplication, Division, Equality , Not Allowed : Addition, Subtraction B) Allowed : Addition, Subtraction , Not Allowed : Multiplication, Division, Equality C) Allowed : Multiplication, Division , Not Allowed : Addition, Subtraction, Equality D) Allowed : Addition, Multiplication , Not Allowed : Subtraction, Division, Equality E) Allowed : Addition, Subtraction, Equality , Not Allowed : Multiplication, Division

  • Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...

    Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two integer numbers as input and ask the user if he need to compute addition, subtraction, remainder, division, or multiplication then print the result. Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), …. And so on. The output must be something like: Enter the first integer number: 5 Enter the second integer number: 3 Which operation? 1...

  • Question 20: Write a python program that will perform the operations of simple calculator. The operations...

    Question 20: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210

  • RAPTOR PROGRAMMING Write a program which will receive two integer values as input. Then prompt the...

    RAPTOR PROGRAMMING Write a program which will receive two integer values as input. Then prompt the user to choose one of the following operations and produce an output with the selected operation. 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulo Division Example output with response: Please enter an input: 2 Please enter another input: 3 Please choose from the follow: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulo Division Output: 2 % 3 is 2.

  • Write a java calculator program that perform the following operations: 1. function to Addition of two...

    Write a java calculator program that perform the following operations: 1. function to Addition of two numbers 2. function to Subtraction of two numbers 3. function to Multiplication of two numbers 4. function to Division of two numbers 5. function to Modulus (a % b) 6. function to Power (a b ) 7. function to Square root of () 8. function to Factorial of a number (n!) 9. function to Log(n) 10. function to Sin(x) 11. function to Absolute value...

  • Multiplication and Division using PIC16F PIC16 is a very basic microcontroller with the capability of limited...

    Multiplication and Division using PIC16F PIC16 is a very basic microcontroller with the capability of limited arithmetic and logical operations. It has dedicated arithmetic instructions for addition, subtraction, increment and decrement. If we want to perform a multiplication and division operations then we need to write a program for it. Multiplication is nothing but repeated addition. However, division can be implemented using repeated subtraction. This mini-project presents assembly or C language program for the multiplication and division of two 8-bits...

  • #PYTHON# In this exercise you will write code which loads a collection of images (which are...

    #PYTHON# In this exercise you will write code which loads a collection of images (which are all the same size), computes a pixelwise average of the images, and displays the resulting average. The images below give some examples that were generated by averaging "100 unique commemorative photographs culled from the internet" by Jason Salavon. Your program will do something similar. Write a function in the cell below that loads in one of the sets of images and computes their average....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT