# I want to reshape my blob in android from 1\*3\*62\*62 to 1\*62\*62\*3

**URL:** <https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548>\
**Category:** Android/Java\
**Tags:** dnn\
**Created:** [December 17, 2024, 1:49pm UTC](https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548 "2024-12-17T13:49:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal2.bansal](https://avatars.discourse-cdn.com/v4/letter/v/e47c2d/32.png) [@vishal2.bansal](https://forum.opencv.org/u/vishal2.bansal)\
**Post date:** [December 17, 2024, 1:49pm UTC](https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548/1 "2024-12-17T13:49:40Z")

</div>

val blob = Dnn.blobFromImage(  
frame, 1.0/255/0,  
Size(62.0, 62.0))  
here blob dimension is of : `1*3*62*62`  
i want the dimension in shape: `1*62*62*3`

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 17, 2024, 8:18pm UTC](https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548/2 "2024-12-17T20:18:39Z")

</div>

what you want here, woulld not be posssible as a reshape, memory has to be reorderhed (which `Dnn.blobFromImage` does …).

why do you need it this way ? (uncommon for cnn’s)  
do you want to run a specific network ?  
using opencv’s Dnn class ?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [December 18, 2024, 7:57am UTC](https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548/3 "2024-12-18T07:57:13Z")

</div>

NCHW \<\> NHWC conversions are very common.  
“traditionally” images are loaded (N)HWC.  
DNNs prefer NCHW. yours should too, as already stated.

OpenCV’s blobfromimage/images does that implicitly. and so does the imagesfromblob function.

> Returns  
> 4-dimensional [Mat](https://docs.opencv.org/3.4/d3/d63/classcv_1_1Mat.html) with NCHW dimensions order.

[https://docs.opencv.org/3.4/d6/d0f/group\_\_dnn.html#ga29f34df9376379a603acd8df581ac8d7](https://docs.opencv.org/3.4/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7)

---

<div class="post-metadata">

**Author:** ![vishal2.bansal](https://avatars.discourse-cdn.com/v4/letter/v/e47c2d/32.png) [@vishal2.bansal](https://forum.opencv.org/u/vishal2.bansal)\
**Post date:** [December 18, 2024, 12:18pm UTC](https://forum.opencv.org/t/i-want-to-reshape-my-blob-in-android-from-1-3-62-62-to-1-62-62-3/19548/4 "2024-12-18T12:18:15Z")

</div>

@berak @crackwitz thanks for your answer.

1. Actually in android i was using a model in onnx format which requires the blob input dimension of type (1\* 62 \* 62 \*3)which is NHWC.
2. But as you stated that Dnn’s prefer NCHW and if i reshape the blob then my blob input might release the memory. Currently blob dimension: (NCHW(1 \* 3 \* 62 \* 62)).
3. So i want to way to convert the blob from (NCHW -to → NHWC). I have input image so if their is other method which can give me blob of type (NHWC) that would also works.
4. Currently i also tried with Core.TransposeND(input\_mat,order,output\_mat). But that also won’t work and it released the memory of input\_mat.

```auto
std::vector<int> order = {0, 2, 3, 1};
Mat inp, out; // inp: NCHW, out: NHWC
transposeND(inp, order, out);

```
