I am new in matalb.

1 view (last 30 days)
  1. You have been asked to write a function that processes images. An image is represented by a matrix in Matlab. In order to do some processing corner values of the matrix are required. Write a function that returns four outputs for four corners. e.g
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
[TL, TR, BL, BR] = imageCorners(A)
TL = 1, TR = 3, BL = 7, BR = 9
  3 Comments
vibhuti mahant
vibhuti mahant on 12 Oct 2021
sure i do that thank you so much for help.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 11 Oct 2021
Edited: Image Analyst on 11 Oct 2021
You can get a value from A by specifying the row and column, like A(row, column). Rows and columns start numbering at 1. The last one is referenced by the shortcut word "end", like A(1, end) or A(end, end), and so on. So use 1 and end in between the parentheses to get the corresponding corners. Of course you'll need all 4 combinations of 1 and end to get all 4 corners.
Use function to define the function
function [TL, TR, BL, BR] = imageCorners(A)
TL = ........
and then when you call it, define A and accept all 4 outputs. So your script would look like:
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
[TL, TR, BL, BR] = imageCorners(A) % Call the function in the main part of the script.
% Define the function below the main part, or in a separate m-file called
% imageCorners.m. If the function is in your test script file, then be
% sure to end your function with the "end" keyword.
function [TL, TR, BL, BR] = imageCorners(A)
TL = ........ You do this part yourself...
end
  3 Comments
vibhuti mahant
vibhuti mahant on 12 Oct 2021
ok i got it thank you so much its g8t help.
A =
1 2 3
4 5 6
7 8 9
TL =
1
TR =
3
BL =
7
BR =
9

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by