Create an ROI based on matrix values

2 visualizaciones (últimos 30 días)
Dor Simon
Dor Simon el 29 de Mayo de 2017
Respondida: Walter Roberson el 29 de Mayo de 2017
Hi all,
Trying to figure out how to auto-create an ROI (region or interest) based on values in a matrix. For that matter, the matrix has binary values, 0 or 1. If the cell has '1', than I it's inside an ROI, '0' is out. So as a result, I would have for that matrix - ROI's that bound the areas where '1' is the value.
Thanks, Dor

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Mayo de 2017
That matrix is already the ROI.
Potentially you might want to do something like
ROI = imfill(YourMatrix, 'holes');
if you want to convert things like
0 0 0 0 0
0 1 1 1 0
0 1 0 1 0
0 1 1 1 0
0 0 0 0 0
to
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
If for some reason you only want the coordinates of the outside boundary (which is not how you typically use ROIs) then https://www.mathworks.com/help/images/ref/bwboundaries.html or https://www.mathworks.com/help/images/ref/bwtraceboundary.html
If you want the smallest enclosing rectangle around the area that has 1's (which is often used with ROIs), then use regionprops() with the 'boundingbox' option.

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by