Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loaded JPG image, returns ndarray with 4 channels? #32

Open
takahashi64 opened this issue Apr 20, 2017 · 2 comments
Open

Loaded JPG image, returns ndarray with 4 channels? #32

takahashi64 opened this issue Apr 20, 2017 · 2 comments
Labels

Comments

@takahashi64
Copy link

takahashi64 commented Apr 20, 2017

I expected the JPG image to have three channels. Renamed file to have JPEG extension, but same result. Any ideas? Cheers.

>         var img = "";
undefined
>         getPixels("test/images/file000555007525.jpeg", function(err, pixels) {
...             if(err) {
.....                 console.log("Bad image path");
.....                 return
.....             }
...             console.log("got pixels", pixels.shape.slice())
...             img = pixels;
...         });
undefined
> got pixels [ 2240, 1680, 4 ]
img
View3dbuffer {
  data: <Buffer 6c 88 c6 ff 6c 88 c6 ff 6a 88 c6 ff 6d 89 c7 ff 6d 8b c9 ff 70 8b cc ff 70 8e ce ff 72 90 d0 ff 6e 8e cd ff 70 90 cf ff 72 92 d1 ff 6e 8e cd ff 68 88 ... >,
  shape: [ 2240, 1680, 4 ],
  stride: [ 4, 8960, 1 ],
  offset: 0 }
>
@benwiley4000
Copy link
Collaborator

benwiley4000 commented Jul 14, 2017

Currently all the channel values are hard-set to 4, and not actually read from the images, though it should be possible to compute most if not all of them using our existing dependencies.

Is this blocking your project? I would assume in your case it's safe to assume any jpg will have three channels, though this may not be the case if the image is CMYK-encoded, or includes the rare Jpeg alpha transparency channel.

Note: this should go in a minor release rather than a patch release since the expected behavior doesn't seem to have ever been implemented.

@bobmoff
Copy link

bobmoff commented Nov 21, 2018

I was also very confused by this behaviour. I expected 3 channels, but got 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants