Question

In: Computer Science

Reflection Write a program in Python or Matlab to perform reflection of an image about its...

  1. Reflection Write a program in Python or Matlab to perform reflection of an image about its y-axis. Apply your program to an image of your choice to demonstrate the reflection. Do not use transpose library.

Solutions

Expert Solution

A colored image consists of 3-D matrix values where each plane is for each color channel of RGB colors.

To reflect an image about y-axis, we need to start with the bottom row and end with the first row for all the 3 colors. For example take a binary colored image ( 1 plane => 2-D matrix) as

1 2 3 4

5 6 7 8

9 10 11 12

To reflect it about y-axis, we write this as

9 10 11 12

5 6 7 8

1 2 3 4

We can do this in MATLAB, by starting with the bottom row (denoted by end) and decreasing this by -1 at each iteration till 1.

the end:-1:1 is the code for the same in MATLAB.

Program:

img = imread('example.jpg'); % read image

subplot(2,1,1); % subplot 1

imshow(img); % display image

title('Original Image');

y_img = img(end:-1:1, :, :); % reflected image, starting with last row and end with the first row, y remains same

subplot(2,1,2); % subplot 2

imshow(y_img); % display the reflected image

title('Image reflected about y-axis');


Related Solutions

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.
(Optics) Write a program in Matlab that can plot the amplitude and energy reflection and transmission...
(Optics) Write a program in Matlab that can plot the amplitude and energy reflection and transmission coefficients for both polarizations as functions of incidence angle for any incidence dielectric medium into any other dielectric medium.
Using MATLAB (a) Write a computer program capable of zooming and shrinking an image by pixel...
Using MATLAB (a) Write a computer program capable of zooming and shrinking an image by pixel replication. Assume that the desired zoom/shrink factors are integers.
Language Python with functions and one main function Write a program that converts a color image...
Language Python with functions and one main function Write a program that converts a color image to grayscale. The user supplies the name of a file containing a GIF or PPM image, and the program loads the image and displays the file. At the click of the mouse, the program converts the image to grayscale. The user is then prompted for a file name to store the grayscale image in.
Who knows to do this topic with python code? Write a program to perform the following...
Who knows to do this topic with python code? 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...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The...
Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The program will add, subtract, multiply, or divide 2 numbers and provide the average of multiple numbers inputted from the user. You need to define a function named performCalculation which takes 1 parameter. The parameter will be the operation being performed (+,-,*,/). This function will perform the given prompt from the user for 2 numbers then perform the expected operation depending on the parameter that’s...
Write a GUI based Python program that will allow the user to perform (i) generate RSA...
Write a GUI based Python program that will allow the user to perform (i) generate RSA keys, (ii) encrypt a given message and (iii) decrypt the message without using any cryptographic library. Your program will generate the values of p unless the user provides them manually. Then the program will generate the keys (private and public). Then the program will allow the user to enter his/her message to be encrypted. Finally, the program will perform the decryption operation as well....
MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
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):
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT