# How to find the minimum and maximum non-zero indice of matrix?

3 vues (au cours des 30 derniers jours)
John Wray le 29 Déc 2016
Commenté : John Wray le 29 Déc 2016
Assume:
a = [0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
0 1 0 0 1 0
0 0 1 1 0 0
0 0 0 0 0 0]
Obviously, the minimum non-zero column indice is 2, max is 5
the minimum non-zero row indice is 3, max is 6
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Image Analyst le 29 Déc 2016
Not sure what you're after. If you really want the min and max row and column only , then you can do what the others showed you, using find(), min(), and max().
If you want the min and max row and column because you want the bounding box because you want to crop out a rectangular region of interest from your image then you can use
props = regionprops(labeledImage, 'BoundingBox');
to get the bounding boxes of all the non-zero regions in your entire image. You can use the bounding box directly in imcrop() to crop out a region of interest. See my Image Segmentation Tutorial in my File Exchange for a full demo.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
John Wray le 29 Déc 2016
Thanks, this really helps

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by