Question

Write a program that asks the user for the name of an image, the name of an output file. Your program should then save the up
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#inbuild modules are imported
import cv2
import numpy as np

#reading image from the pc
image = cv2.imread('hunterLogo.png')

#making a copy of the readed image
image_copy = np.copy(image)

#finding height and width of the image
height = image_copy.shape[0]
width= image_copy.shape[1]
half_width = (int)(width/2)
half_height = (int)(height/2)

#cropping the image using slicing
cropped_image = image_copy[0:half_height, half_width:width]

#saving the image using cv2 with 'logoUR.png'
cv2.imwrite('logoUR.png',cropped_image)

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user for the name of an image, the name of an output file. Your pro...
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 a PYTHON program that asks the user for the name of the file. The program...

    Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • Python3 Write a program to apply a 'negative' filter on a greyscale image. The program should ask the user to enter a filename, open this file, perform the transformation (as described below)...

    Python3 Write a program to apply a 'negative' filter on a greyscale image. The program should ask the user to enter a filename, open this file, perform the transformation (as described below) and then save the negative version of the image to the file 'output.png'. To perform the negative effect, set each pixel in the output image to the opposite colour value than the corresponding pixel in the input image. For example, a colour value of 0 would become 255,...

  • PYTHON3 Write a program to apply a 'negative' filter on a greyscale image. The program should...

    PYTHON3 Write a program to apply a 'negative' filter on a greyscale image. The program should ask the user to enter a filename, open this file, perform the transformation (as described below) and then save the negative version of the image to the file 'output.png'. To perform the negative effect, set each pixel in the output image to the opposite colour value than the corresponding pixel in the input image. For example, a colour value of 0 would become 255,...

  • In Java, write a program that asks the user for the name of a file. The...

    In Java, write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage

  • Write a program in java that asks a user for a file name and prints the...

    Write a program in java that asks a user for a file name and prints the number of characters, words (separated by whitespace), and lines in that file. Then, it replaces each line of the file with its reverse. For example, if the file contains the following lines (Test1.txt): This is a test Hi there Output on the console: Number of characters: 22 Number of words: 6 Number of lines: 2 Data written to the file (Test1.txt): tset a si...

  • IN PYTHON Write a program that asks the user for the name of a file ....

    IN PYTHON Write a program that asks the user for the name of a file . The program should display the contents of any file with each line preceded with a line number followed by a colon. The line number should start at 1

  • ask the user to specify the input file, ask the uscr to specify the output filc,...

    ask the user to specify the input file, ask the uscr to specify the output filc, make a plot of the fraction of the total population that are children over time from the data in input file, and store the plot in the output file the user specified. o o a o A sample run of the program Enter nane of input file: DHS 2015 2016.cBv Enter name of output file: dhePlot.png which produccs an output 054 Fraction Children 052...

  • FiveOnly.java: Write a program that asks the user for the name of a file. The program...

    FiveOnly.java: Write a program that asks the user for the name of a file. The program should display only the first five lines of the file’s contents. If the file contains fewer than five lines, it should display the file’s entire contents. See Challenge 13 on p265. Hope this is enough. if you need the txtbook page let me know!

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