neurodata / ndstore

code for storing neurodata images and image annotations
http://neurodata.io
Apache License 2.0
38 stars 12 forks source link

JPEG cutout service broken if xdim != ydim #275

Closed jbms closed 8 years ago

jbms commented 8 years ago

The JPEG cutout service does not correctly handle requests if xdim != ydim.

For example:

This gives correct output, an image with width 50 and height 100, and displays correctly: http://openconnecto.me/ocp/ca/kasthuri11/image/jpeg/0/5000,5050/5000,5050/500,502/

This gives incorrect output, an image with width 40 and height 100, and displays incorrectly: http://openconnecto.me/ocp/ca/kasthuri11/image/jpeg/0/5000,5050/5000,5040/500,502/

The linearized data is correct, the dimensions are just wrong --- the width should be 50 and the height 80. Because the JPEG image is created with the correct data but the wrong dimensions, the JPEG compression likely does not work nearly as well.

The bug is due to this line in ocpcarest.py: cubedata = cubedata[0,:,:,:].reshape(xdim*zdim, ydim)

It should be: cubedata = cubedata[0,:,:,:].reshape(ydim*zdim, xdim)