help with location of within image

1 visualización (últimos 30 días)
Yogesh Bhambhwani
Yogesh Bhambhwani el 22 de Oct. de 2020
Comentada: Rik el 23 de Oct. de 2020
I would like help with the following,
You will then pass the i, j as inputs (along with any other necessary information) to a local function called indexLocation(i,j,..,…). (You must write this function!) The outputs of the function must be one of the following:
INSIDE (when the location i,j is not on the border)
NE (when the location i,j is a North East corner)
TOP (when the location i,j is on the top boundary of the image, and is not a corner)
RIGHT (when the location i,j is on the right boundary of the image and is not a corner)
BOTTOM (when the location i,j is on the bottom boundary of the image and is not a corner)
SE (when the location i,j is South East corner )
SW (when the location i,j is South West corner)
NW (when the location i,j is North West corner)
LEFT (when the location i,j is on the left boundary of the image, and is not a corner)
The attachment is what I have.
%Edit Rik: copied code from attachment to body
myimage_color = imread('sunflower1.jpg');
imshow(myimage_color);
myimage_grayscale = rgb2gray(myimage_color);
figure
imshow(myimage_grayscale);
[rows,cols] = size(myimage_grayscale);
N = rows;
M = cols;
for j=1:M
for i=1:N
myimage_grayscale(i,j)
end
end
  4 comentarios
Yogesh Bhambhwani
Yogesh Bhambhwani el 23 de Oct. de 2020
I think the function has to go within my nested loop and im just confused how to do this all we learned was how to change the color of photos. I don't know what other inputs I would need in addition to i and j. For the corner question I don't I would assume the extreme corner the question wasn't specific about it.
Rik
Rik el 23 de Oct. de 2020
I would suggest taking a step back.
You need to create a function. That means one of your lines of code must start with the function keyword.
What does the function need to do? It needs to respond what kind of location the coordinates describe. Say I tell you I want to know if the pixel on row 200 and column 255 is on the edge of my image or not. What do you need to know before you can answer my question?
When writing a function, try to stick to this order:
  1. Write the purpose in a single line. This will be the first comment line in your function. Try to keep it below 79 characters.
  2. Describe the syntax. What inputs should your function be able to handle? Should it work for arrays, or only for scalar input? What data types are allowed?
  3. Describe the expected output. What should the user expect?
  4. Write the logical steps in comments.
  5. Only now can you implement your steps in actual Matlab code.
That order is not perfect nor is it law, but it is generally a good strategy.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by