# Subarray view and parent indexing

**URL:** https://discourse.julialang.org/t/subarray-view-and-parent-indexing/47388
**Category:** General Usage
**Created:** [September 28, 2020, 3:39am UTC](https://discourse.julialang.org/t/subarray-view-and-parent-indexing/47388 "2020-09-28T03:39:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)
#### Post date: [September 28, 2020, 3:39am UTC](https://discourse.julialang.org/t/subarray-view-and-parent-indexing/47388/1 "2020-09-28T03:39:03Z")

</div>

This snippet:

```julia
using ImageMorphology

a = reshape(collect(1:36), 6, 6)
labels = label_components(a .> 16, trues(3,3))
box = component_boxes(labels)[2]

```

returns a bounding box:

```julia
2-element Array{Tuple{Int64,Int64},1}:
 (1, 3)
 (6, 6)

```

I’m looking for a convenient notation to use `box` for operations inside subarray delimited by it. Is there a shorter way to write this view:

```julia
v = @view a[box[1][1]:box[2][1], box[1][2]:box[2][2]]

```

Is there an easier way to convert index `i` of subarray `v` into an index `j` of parent array `a` than:

```julia
i = argmax(v)
j = i + CartesianIndex(box[1]) - CartesianIndex((1, 1))

```
