Question

In: Computer Science

Write a program that creates an image of green and white horizontal stripes. Your program should...

Write a program that creates an image of green and white horizontal stripes. Your program should ask the user for the size of your image, the name of the output file, and create a .png file of stripes.

For example, if the user enters 10, your program should create a 10x10 image, alternating between green and white stripes. A sample run of the program: Enter the size: 10 Enter output file: 10stripes.png

Another sample run of the program: Enter the size: 50 Enter output file: 50stripes.png

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

# Importing the Required Libraries
import cv2
import numpy as np

# Input Prompt for Size and Output File Name
size = int(input("Enter the size: "))
output_file = input("Enter output file: ")

# Creating an Image to make it as per the requirement
image = 255 * np.ones(shape=[size,size, 3], dtype=np.uint8)

# Number of Green Stripes
n = size//2

# Marking the Count for Green Stripes Coordinates
j=0

# Iterating for stripe printing
for i in range(0,n):
   # cv.line is used to draw lines
   # Syntax: cv2.line(image,start_coordinates,end_coordinates,color,thickness)
   image=cv2.line(image, (0,j), (size,j), (0,255,0),1)
   j=j+2

# Writing the processed image on to the specified path
cv2.imwrite(output_file,image)


Related Solutions

Write a program that creates a two-dimensional array initialized with test data. The program should have...
Write a program that creates a two-dimensional array initialized with test data. The program should have the following functions: Hi There I really appreciate your help with this project. ▪ getTotal . This function should accept a two-dimensional array as its argument and return the total of all the values in the array. ▪ getAverage . This function should accept a two-dimensional array as its argument and return the average of all the values in the array. ▪ getRowTotal ....
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to...
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to the specifications that the user desires. It walks the user through ordering, giving the user choices, which the program then uses to decide how to make the pizza and how much the cost of the pizza will be. Note: Use dialog boxes for communicating with the user. Remember to use the JOptionPane class which is the graphical user interface (GUI) and Comments that are...
Write a program that creates a Singleton class to connect to two databases. The program must...
Write a program that creates a Singleton class to connect to two databases. The program must provide two instances of this class. One instance for connecting to MySQL database and the other for connecting to Oracle database.
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to...
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to the specifications that the user desires. It walks the user through ordering, giving the user choices, which the program then uses to decide how to make the pizza and how much the cost of the pizza will be. Note: Use dialog boxes for communicating with the user. Remember to use the JOptionPane class which is the graphical user interface (GUI) and Comments that are...
In this problem, you will write a program that reverses a linked list. Your program should...
In this problem, you will write a program that reverses a linked list. Your program should take as input a space-separated list of integers representing the original list, and output a space-separated list of integers representing the reversed list. Your algorithm must have a worst-case run- time in O(n) and a worst-case space complexity of O(1) beyond the input. For example, if our input is: 5 7 1 2 3 then we should print: 3 2 1 7 5 Please...
Need a program in java that creates a random addition math quiz The program should ask...
Need a program in java that creates a random addition math quiz The program should ask the user to enter the following The smallest and largest positive numbers to be used when generating the questions - The total number of questions to be generated per quiz - The total number of the quiz's to create from then the program should generate a random math (Just addition) quiz from what the user entered
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.
Write a program that is capable of detecting the color brown in an image taken by...
Write a program that is capable of detecting the color brown in an image taken by a webcam using OpenCV python code.
Write a menu program to have the above options for the polynomials. Your menu program should...
Write a menu program to have the above options for the polynomials. Your menu program should not use global data; data should be allowed to be read in and stored dynamically. Test your output with the data below. Poly #1: {{2, 1/1}, {1, 3/4}, {0, 5/12}} Poly #2: {{4, 1/1}, {2, -3/7}, {1, 4/9}, {0, 2/11}} provide a C code (only C please) that gives the output below: ************************************ *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1....
Write a program that creates an output file named rand_nums.txt. Open the file and write 100...
Write a program that creates an output file named rand_nums.txt. Open the file and write 100 random integers between -50 and +50 (inclusive) to the file. Be sure to handle any file IO exceptions. Remember to close the file. Write a program that opens rand_nums.txt for input. Create two output files pos.txt and neg.txt. Read through the input file, one line at a time, converting each line into an integer (no exception handling, yet). If the number is positive, write...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT