getMinMax seems to be dramatically slowing down image decoding

Describe Your Question

I have built a viewer using Cornerstone to display multiframe dicom cines; the stackPrefetch utility has been helpful in allowing us to load frames up front before attempting to play the video, but the load time for decoding the images has been extremely non-performant, taking 20+ seconds to load a cine with only 412 frames.

Using Chrome’s performance monitoring tab I was able to pinpoint the scripting bottleneck: the getMinMax function here. It seems as though looping over millions of pixels for over a hundred frames is a bit taxing for my viewer.

However, I uploaded the exact same sample dicom file to OHIF’s viewer (at OHIF Viewer) and somehow the same file loads MUCH faster there despite having to do the same intensive computation. I have been referencing OHIF’s code and configuring Cornerstone the exact same way but I cannot for the life of me figure out how OHIF is able to speed through this getMinMax function so much more efficiently.

What steps can we follow to reproduce the bug?

Unfortunately I cannot link to a public instance of our viewer at the moment. Just hoping someone had some familiarity with performance improvements made to OHIF, specifically regarding the getMinMax computation.

1 Like