Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*** Matlab code *** Please answer e,f,g,h Given a 100 x 100 uint8 matrix A repre

ID: 3747773 • Letter: #

Question

*** Matlab code ***

Please answer e,f,g,h

Given a 100 x 100 uint8 matrix A representing a grayscale image, write a few lines of code to do each of the following. Try to avoid using loops. Sort all the intensities in A, put the result in a single 10,000-dimensional vector x, and plot the values in x. Display a figure showing a histogram of A's intensities with 32 bins. Create and display a new binary image the same size as A, which is white wherever the intensity in A is greater than a threshold t, and black everywhere else. Generate a new image (matrix), which is the same as A, but with A's mean intensity value subtracted from each pixel. Set any negative values to 0. Use rand to write a function that returns the roll of a six-sided die. e. f. Let y be the vector: y [1:61 Use the reshape command to form a new matrix z whose g. Use the min and find functions to set x to the single minimum value that occurs in A, and h. Let v be the vector: v [1 8 8 2 1 3 9 8]. Use the unique function to compute the total first column is [1, 2, 3]', and whose second column is [4, 5, 6]'. set r to the row it occurs in and c to the column it occurs in number of unique values that occur in V.

Explanation / Answer

e)

function side = roll()
side = randi(6);
end

f)

y = [1:6]
reshape(y, [3,2])

g)

x = min(A(:))
[r,c] = find(A==x, 1)

h)

v = [1 8 8 2 1 3 9 8]
size(unique(v), 2)