Skip to content

Commit 15eabf9

Browse files
committed
Add callout on advanced indexing with Boolean and integer arrays
1 parent 6900150 commit 15eabf9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

episodes/08-connected-components.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,5 +715,22 @@ This will produce the output
715715
> > {: .language-python}
716716
> >
717717
> > ![Objects colored by area](../fig/shapes-01-objects-coloured-by-area.png)
718+
> >
719+
> > > You may have noticed that in the solution, we have used the
720+
> > > `labeled_image` to index the array `object_areas`. This is an
721+
> > > example of [advanced indexing in
722+
> > > Numpy](https://numpy.org/doc/stable/user/basics.indexing.html#advanced-indexing)
723+
> > > The result is an array of the same shape as the `labeled_image`
724+
> > > whose pixel values are selected from `object_areas` according to
725+
> > > the object label. Hence the objects will be colored by area when
726+
> > > the result is displayed. Note that advanced indexing with an
727+
> > > integer array works slightly different than the indexing with a
728+
> > > Boolean array that we have used for masking. While Boolean array
729+
> > > indexing returns only the entries corresponding to the `True`
730+
> > > values of the index, integer array indexing returns an array
731+
> > > with the same shape as the index. You can read more about advanced
732+
> > > indexing in the [Numpy
733+
> > > documentation](https://numpy.org/doc/stable/user/basics.indexing.html#advanced-indexing).
734+
> > {: .callout}
718735
> {: .solution}
719736
{: .challenge}

0 commit comments

Comments
 (0)