Create a binary image from a 2-dimensional binary [0 1] matrix
Mostrar comentarios más antiguos
I've been trying for a while to draw shapes in the binary image function and it hasnt worked, I do not understand how to plot the coordinates of the shapes. Does anyone have any useful links or tips i can utilise?
Respuesta aceptada
Más respuestas (1)
Jan
el 21 de Nov. de 2022
What have you tried?
M = false(100, 100);
M(26:50, 76:100) = true; % The black rectangle
Instead of setting all pixels to black by a single true on the righ side, you can insert a triangle shape:
M(1:5, 1:5) = tril(true(5));
See also: triu, rot90, transpose.
4 comentarios
Bear in mind that the previous interpretation of the assignment stated that the blobs were black on white, so you'll have to complement M after assembling it.
% ... insert all the blobs
M = ~M; % then invert
I can't know whether that interpretation is correct, since I'm not the one who was given the assignment and any explanation that came with it.
Nicholas
el 21 de Nov. de 2022
Nicholas
el 21 de Nov. de 2022
So from this we can tell that the image is to be black-on-white and numeric. We can also tell that none of these answers will meet the requirements. The assignment instructs to do it row-wise using a loop (as maddening as that sounds). The prior question I answered on this assignment used a loop. I'll leave it to you to find it.
As an aside, when given an assignment that explicitly tells me to do things the dumb inefficient way, I'd tend to do it the way I'm told, and then also do it in a better way just to point out the absurdity of teaching students how to shoot themselves in the foot. Of course, the TA grader didn't write the assignment, but it's the thought that counts -- and usually the TA knows it's BS too.
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
