Write the function compute_histogram, in Matlab, that takes a grayscale image as input and returns a length 256 vector h which is the normalized histogram of the values in the image. h should have values from 0 to 1 and its components should sum to 1.
function [h]=compute_histogram(img)
[n,m] = size(img);
h = zeros(562);
for i =1:n
for j =1:m
h(img(i,j)) = h(img(i,j))+1;
end
end
% normalize
total_pixel=n*m;
h=h./total_pixel;
end
main.m
img = imread('pandu562.png');
figure(1);
imshow(img);
h = compute_histogram(img);
figure(2);
bar(h,1,'b');
Write the function compute_histogram, in Matlab, that takes a grayscale image as input and returns a...
MATLAB QUESTION Write a MATLAB function called vector_input that takes no inputs and returns no outputs. Instead, when called, it gives control to the user and asks the user to input a length-3 vector. Then the function prints: The sum of ___, ____, and ____ is ____. [new line] where the first three blanks are filled by each element in input vector, and the last blank is the sum of all three elements.
MATLAB Write a function maxContent(arr) that takes a cell array arr as input and returns the longest string and largest number in arr. If there are two character arrays of same length, the function should return one of them. Assume that integers in the cell array are nonnegative.
Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write...
Matlab: Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. As a second output argument called mmm, it provides the difference between the maximum and minimum element in the entire matrix. See the code below for an example: >> A = randi(100,3,4) A = 66 94 75 18 4 68 40 71 85 76...
b) (2.5 marks) Write a Matlab user defined function that takes the letter grades (i.e. AABBC) as input and returns if the student entitled to the honor list or not. The student is considered in the honor s f he or she satisfies the following three conditions: a. An average GPA of 3.5 and above and b. At least two classes with A mark and e. no class with a mark less than C (i.e. no D or F) The...
Please use matlab to code this program. Write a computer program that takes as input an angle β and the components of a position vector in frame A (i.e. r). The transformation from frame A to frame B is a rotation about the 1-axis. Your code should calculate the DCM CAB, and the components of the vector in frame B (i.e.rB. Your code should output all of the following, including a label and units (if applicable) for each: CAB 4.8...
This code NEEDS TO BE DONE IN MATLAB!!!! Write a function that takes one input, an integer number n, and returns a matrix that is nxn, where the value of each number is the distance from the upper-left to bottom-right diagonal. (Use while loops if you can!) Numbers below the diagonal should be negative, and numbers above the diagonal should be positive. For example, if your input was 5, your output would be: 0 1 2 3 4 -1 0...
JAVA - Write a recursive function that takes a linked list as input and returns all of the elements in the linked list. Input: 1, 2, 3, 4, 5 Output: (1+2+3+4+5)/5 = 3 What I have: public static int findMean (Node head, Node cur, int n){ int average = 0; if (head == null){ if(n == 0) return 0; } if (n > 0){ int sum = n + findMean(head, head.next, n -1); average = (sum)/n; } return average; }...
Repost pls show clear and correct codes in matlab.. Question 2. Write a MATLAB Function my-fun that takes as its input a vector of numeric values nums and returns a vector whose values are exactly/only the indicies of nums whose values are non- zero. You may not use any built-in MATLAB functions - i.e. find Sample call(s): CALL 1: my-fun( [8 05 0] ) \% would evaluate [1 3] CALL 2: my-fun ( [0 9 0 1 0] ) \%...
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:...