Question

(MATLAB example)Write a function that generates an image (a matrix) that contains a circular object with a value of 1 and 0 elsewhere when image size, matrix size, circle center and circle radius are...

(MATLAB example)Write a function that generates an image (a matrix) that contains a circular object with a value of 1 and
0 elsewhere when image size, matrix size, circle center and circle radius are given:
function myImage = circle(imageSize, matrixSize, center, radius);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function myImage = Circle(imagesize,matrixsize,center,radius)
Orig = ones(imagesize,imagesize);
imshow(Orig);

[columnsInImage rowsInImage] = meshgrid(1:imagesize, 1:imagesize);
% Next create the circle in the image.
circlePixels = (rowsInImage - center).^2 + (columnsInImage - center).^2 <= radius.^2;
image(circlePixels);
colormap([0 0 0; 1 1 1]);
title('Binary image of a circle');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Binary image of a circle 50 100 150 200 250 300 350 400 450 500 50 100 150 200 250 300 30 40 4500

Add a comment
Know the answer?
Add Answer to:
(MATLAB example)Write a function that generates an image (a matrix) that contains a circular object with a value of 1 and 0 elsewhere when image size, matrix size, circle center and circle radius are...
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
  • 1. Write a short MATLAB script or function (m-file) that generates the functions (t)eu(t) for a =...

    Only calculate manually 1. Write a short MATLAB script or function (m-file) that generates the functions (t)eu(t) for a = 0.1. Plot the value of x(t). Since the e-af almost attenuates to 0 after 5T, where T1. So make your time vector from 0 to 5T would be enough to capture the signal.) 2. Using the definition of the FT (1), manually calculate the FT of the given functions in previous exercise 0O x(t)e 3. Plot the absolute values and...

  • MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference...

    MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by pi*r^2 and the circumference is 2*pi*r. The function is called areaCircum. Example: areaCircum(input value) %} % Place your function call here

  • Write a function in Matlab (or Java) as follows: function Img2=Convolution(Img, mask); %Input: Img is the original image data matrix, mask is square matrix, could be 2x2, 3 x 3 or size %Output: Img...

    Write a function in Matlab (or Java) as follows: function Img2=Convolution(Img, mask); %Input: Img is the original image data matrix, mask is square matrix, could be 2x2, 3 x 3 or size %Output: Img2 is the result image Test the function. Read an image file, apply the edge detection filters (i.e., masks) to see whether it works well. Try at least 3 filters: Sobel, Robert, Prewitt.

  • 1. Write a MATLAB function that takes a matrix, a row number and a scalar as...

    1. Write a MATLAB function that takes a matrix, a row number and a scalar as arguments and multiplies each element of the row of the matrix by the scalar returning the updated matrix. 2. Write a MATLAB function that takes a matrix, two row numbers and a scalar as arguments and returns a matrix with a linear combination of the rows. For example, if the rows passed to the function were i and j and the scalar was m,...

  • A particle object undergoes uniform circular motion at a speed v around a circle of radius...

    A particle object undergoes uniform circular motion at a speed v around a circle of radius r. Given v and r, the magnitude of centripetal acceleration is a0. Assume when either v or r are changed, the particle remains in uniform circular motion. 1. Suppose the radius of the circle is cut in half. What happens to the magnitude of the centripetal acceleration? choices: the acceleration doubles, acceleration increases by square root of 2, acceleration remains the same, acceleration decreases...

  • matlab 1. Write a MATLAB user-defined function that finds the largest element(s) of a matrix. Name...

    matlab 1. Write a MATLAB user-defined function that finds the largest element(s) of a matrix. Name the function [max_value, max_index] - LASTNAMES matrix max (x), where input argument x is a vector or matrix (not a scalar), and the outputs are the maximum value(s) and indexes of the maximum value(s) of the mput x. Do not use MATLAB functions max() or find(). Use loops and if branches to determine the maximum elements of matrix. Check for correct number and valid...

  • Given a matrix of size NxM sorted in descending order and value V, write a function...

    Given a matrix of size NxM sorted in descending order and value V, write a function which returns -1 if value V is not in the matrix, else it returns 1 if V is in the matrix. The function also computes the position of V in the matrix, that is P= [R, C], where R is the row number of V and C is the column number of V in the matrix, if V is in the matrix (if V...

  • Styles 14. Find the center and radius of the circle with the given equation and graph....

    Styles 14. Find the center and radius of the circle with the given equation and graph. x2 + y2 - 4x-8y +11=0 10+ + -10 -5 5 10 a) Center: b) Radius: c) Graph -10 15. Solve the polynomial inequality - 4x + x2 245. Write answer in interval notation. 1 x + 2 16. Find the domain of the function f(x)=x2 + 3x - 4 Write answer in interval notation.

  • Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots...

    Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots a circle given the coordinates of the center and the radius. For the function name and arguments use circleplot(x,y,R). The input arguments are the and y coordinates of the center and the radius. Use linspace to generte the angle from 0 to π with 100 points. (Hint: the circle equation: x+Rcos and yy-yRsin 0.) This function has no output arguments. Plot the circle using...

  • Use MATLAB to write your codes Consider a matrix A with block matrices as follows: A...

    Use MATLAB to write your codes Consider a matrix A with block matrices as follows: A = {A-11 A_12 0 A-22] It can be shown that the inverse of A can be calculated by inverse of submatrices if A11, and A22 are squared matrices: A^-1 = [A_11 A_12 0 A_22] = [A6-1 _11 -A^-1 _11 A_12 A^-1 _22 0 A^-1 _22 Now consider a Matrix A with following submatrices: A11 = identity matrix A22 = identity matrix A12 = [12...

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