cornerstonejs / cornerstone

JavaScript library to display interactive medical images including but not limited to DICOM
https://docs.cornerstonejs.org/
MIT License
2.06k stars 598 forks source link

Add Step Scaling to reduce Artifacts when scaled #114

Open kofifus opened 7 years ago

kofifus commented 7 years ago

we are having an issue where some big images have artifacts when scaled down.

This is a general canvas issue and a common solution is step scaling see: https://jsfiddle.net/AbdiasSoftware/M4cTx/

Is there a way to make cornerstone step scale images ?

thanks!

swederik commented 7 years ago

Hello,

There is no way to make Cornerstone do this at the moment. It sounds like an interesting technique but it might have a significant effect on performance.

kofifus commented 7 years ago

it will mean keeping an original copy of the image and on each scaling creating scaled copy to work with (As in the fiddle), zooming will definitely end up slower (but maybe ok) but we get the improved image quality plus I imagine window leveling will become very fast as the image is actually much smaller.

On some images (ie 6 mega pixels CR with a grid in front of the plate), the different in quality is quite dramatic.

jpambrun commented 7 years ago

Yeah. This technique is usually referred as mip mapping. Basically, you need to apply a low pass filter when re-sampling in accordance with the Nyquist sampling theorem in order to avoid aliasing. This is the functional equivalent to interpolation for downscaling.

With that said, implementing may be a nice to have, but reduce performance at startup (to build the pyramid) and would take an additional 1/3 memory. The patterns that produce aliasing artefacts are not all that common in medical imaging and they should be examined as close to full resolution for diagnostic purposes.

Once the pyramid computed, it could indeed increase the performance of W/L when zoomed out.

It would be nice if the browser could just apply it by itself just like it does interpolation...

jpambrun commented 7 years ago

@kofifus, Do you have a DICOM file that shows these artefacts that you could share by chance?

jpambrun commented 7 years ago

Nvm, I created a sample : aliasing1000x1000.dcm.zip

Also, a video of the issue: alias.mp4.zip

kofifus commented 7 years ago

ok great, I will try to also get my dicom file to you.

so is there any ideas about solving this with cornerstone ?

thx!

jpambrun commented 7 years ago

It would be nice if you can get any real case showing this issue. I'm not convinced, given the tradeoffs, that this would add significant clinical value.

On Sun, Apr 23, 2017, 6:58 PM Kofifus notifications@github.com wrote:

ok great, I will try to also get my dicom file to you.

so is there any ideas about solving this with cornerstone ?

thx!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/chafey/cornerstone/issues/114#issuecomment-296495126, or mute the thread https://github.com/notifications/unsubscribe-auth/AAr2MLxQG4ZP_gQ8ZajUtTRsGa_-Whq-ks5ry9eTgaJpZM4NCeyr .

kofifus commented 7 years ago

Here is a sample image: https://www.dropbox.com/s/7gxsqajpovnij0a/Cornerstone_aliasing.zip?dl=0

You will see the artifacts as you zoom in and out.

The image was taken with a grid in front of the plate (I can find out the name of the procedure).

Thanks!

jpambrun commented 7 years ago

I could see the artefacts between 30% and 40% magnification.

I suppose mip mapping could be added behind a flag as it increases resource requirements for a limited return.

Unfortunately, I don't think this is on anybody's road map... Contributions are welcomed.

JF

On Mon, Apr 24, 2017 at 12:19 AM Kofifus notifications@github.com wrote:

Here is a sample image: https://www.dropbox.com/s/7gxsqajpovnij0a/Cornerstone_aliasing.zip?dl=0

You will see the artifacts as you zoom in and out.

The image was taken with a grid in front of the plate (I can find out the name of the procedure).

Thanks!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/chafey/cornerstone/issues/114#issuecomment-296521473, or mute the thread https://github.com/notifications/unsubscribe-auth/AAr2MHWVbhF-9JMWdi7A4kUYDLVHV0fAks5rzCLIgaJpZM4NCeyr .

chafey commented 7 years ago

FWIW, most viewers do not worry about this use case as images must be displayed at full resolution (or higher) for interpretation.

On Mon, Apr 24, 2017 at 5:36 AM, Jean Francois Pambrun < notifications@github.com> wrote:

I could see the artefacts between 30% and 40% magnification.

I suppose mip mapping could be added behind a flag as it increases resource requirements for a limited return.

Unfortunately, I don't think this is on anybody's road map... Contributions are welcomed.

JF

On Mon, Apr 24, 2017 at 12:19 AM Kofifus notifications@github.com wrote:

Here is a sample image: https://www.dropbox.com/s/7gxsqajpovnij0a/Cornerstone_aliasing.zip?dl=0

You will see the artifacts as you zoom in and out.

The image was taken with a grid in front of the plate (I can find out the name of the procedure).

Thanks!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <https://github.com/chafey/cornerstone/issues/114#issuecomment-296521473 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAr2MHWVbhF- 9JMWdi7A4kUYDLVHV0fAks5rzCLIgaJpZM4NCeyr .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chafey/cornerstone/issues/114#issuecomment-296650852, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNb2mfe9MTa0lTSM9GMIDIXjOf82h87ks5rzJdmgaJpZM4NCeyr .

FMCalisto commented 1 year ago

As already mentioned here, I suggest the step scaling approach, which involves keeping an original copy of the image and creating scaled copies to work with. This technique is usually referred to as mip mapping, and would require additional memory and potentially reduce performance at startup, but could improve image quality and potentially increase performance for certain functions such as window leveling when zoomed out. It seems that this feature is not currently on anyone's roadmap for development, but we can try to work around.