# NativeImageLoader's asMatrix doesn't seem to work for PNG images

**URL:** <https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099>\
**Category:** Uncategorized\
**Created:** [December 5, 2022, 5:34pm UTC](https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099 "2022-12-05T17:34:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonaldAlan](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/donaldalan/32/369_2.png) [@DonaldAlan](https://community.konduit.ai/u/DonaldAlan)\
**Post date:** [December 5, 2022, 5:34pm UTC](https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099/1 "2022-12-05T17:34:20Z")

</div>

Using datavec’s NativeImageLoader’s asMatrix , when I convert any PNG image to an INDArray, the INDArray is entirely filled with value 6418. That seems wrong! If instead convert a JPG image to INDArray, the INDARRAY looks more reasonable, but there are still a lot of 6148s and other large values, and the values don’t match what I see when I look at the pixels in the BufferedImage. Is the Alpha channel affecting the values ? The documentation on asMatrix is sketchy. Is there someplace that explains the conversion? A requirements doc?

---

<div class="post-metadata">

**Author:** ![DonaldAlan](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/donaldalan/32/369_2.png) [@DonaldAlan](https://community.konduit.ai/u/DonaldAlan)\
**Post date:** [December 5, 2022, 9:13pm UTC](https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099/2 "2022-12-05T21:13:58Z")

</div>

Using `org.datavec.image.loader.ImageLoader` seems to work better:

```auto
 public static BufferedImage toImage(final INDArray features) {
        final INDArray slicedTransposedFeatures = features.slice(0).slice(0).transpose();
        return ImageLoader.toImage(slicedTransposedFeatures);
 }

```

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [December 6, 2022, 9:49pm UTC](https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099/3 "2022-12-06T21:49:30Z")

</div>

@DonaldAlan mind filing an issue with a reproducer so we can look at this thanks!

---

<div class="post-metadata">

**Author:** ![DonaldAlan](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/donaldalan/32/369_2.png) [@DonaldAlan](https://community.konduit.ai/u/DonaldAlan)\
**Post date:** [December 14, 2022, 1:06am UTC](https://community.konduit.ai/t/nativeimageloaders-asmatrix-doesnt-seem-to-work-for-png-images/2099/4 "2022-12-14T01:06:16Z")

</div>

I was unable to reproduce this in a simple test case. (And I noticed that jpgs are lossy, while pngs retain exact values, as expected).
