import numpy as np
import argparse
import glob
import cv2
def detect_edge(im,method):
img = cv2.imread(im, cv2.IMREAD_GRAYSCALE)
rows, cols = img.shape
sobel_horizontal = cv2.Sobel(img, cv2.CV_64F, 1, 0,
ksize=5)
sobel_vertical = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5)
cv2.imshow('Original', img)
if method = 'horizontal' :
cv2.imshow('Sobel horizontal', sobel_horizontal)
else:
cv2.imshow('Sobel vertical', sobel_vertical)
cv2.waitKey(0)
In Python: detect_edge(im, method) Write a function that takes a gray-scale image and detects edges, with...
In this exercise you should write a Python function that computes the histogram of an intensity (gray scale) image. Do not use specifific Python functions for histogram computation (like hist or imhist). Create a new function my_hist and start with the following lines: function [h] = my_hist(im) % H = MY_HIST(IM) computes the histogram for the intensity % image IM (with values from 0 to 255) and returns a vector H % with 256 dimensions % get the image size:...
Write a program that takes an input image in RGB and converts its pixel RGB value to gray scale. In openCV the image data is stored in the “data” pointer. If the location of a pixel is calculated at “index” then R=image.data[index], G= image,data[index+1], and B= image.data[index+2]; To convert a pixel from RGB to gray scale all you need to do is to calculate the average of the three RGB values and store it to the output. output.data[outIndex] = (input.data[index]+...
Pick a gray-scale image, say cameraman.tif or any other file that you can get hold of, and using the imwrite function write it to files of types JPEG, PNG and GIF. What are the sizes of those files? using matlab
Create a new function my_hist and start with the following lines:function [h] = my_hist(im)% H = MY_HIST(IM) computes the histogram for the intensity% image IM (with values from 0 to 255) and returns a vector H% with 256 dimensions% get the image size: M = number of rows, N = number of columns[M, N] = size(im);% initilalize the histogram to zeroh = zeros(1,256);% ... here goes your code ...end % – do not forget the END!To test your function, save...
Write a python function that takes in a string to use as a prompt and shows it to the user. Then get input from the user. If they entered a single sign out of the set +,-,*,/,% return it. If they entered anything else, give them a warning: “You may only enter one of the characters: +- * /%” and then repeat until they enter a correct option.
Write the code in python
5. (10 points) Write a function that takes a square matrix and compute the summation of items on both diagonals. Example: 9 13 5 27 1 11X76 6 0 7 102
Python Write a function that takes in two numbers as parameters. The function will then return the value of the first parameters squared by the second parameter. Print the value of the return statement. Take a screenshot of both your code and your properly executed code after you have run it. Submit the screenshots here along with your .txt file.
Python: Write a function "contrast_adjust", which takes a 2D NumPy array A and an integer c, and returns another NumPy array of the same size, representing the contrast-adjusted image. You can assume that −127 ≤ c ≤ 127.
Write a Python or C++ program that takes as input a directed graph and returns a copy of the graph with all edges reversed. You can only assume that you have access to the sequence of nodes and the sequence of edges of the graph. Generate a random graph and test your program on it.
in python Write a function, named max_of_two, that takes two numbers as arguments and returns the largest of the two values. (Note, this function is actually already provided in Python as max. Do not use the provided function; reason through the logic yourself).