cornerstone icon indicating copy to clipboard operation
cornerstone copied to clipboard

Is it possible to apply colorMap to greyscale PNG or JPG images?

Open cpinchuk opened this issue 5 years ago • 5 comments

I have tried to apply colorMap to a greyscale PNG image and also tried other ways to apply false colour mapping, but the renderer fails miserably by calculating the pixel positions wrongly. Do I need to write my own WebGL RGBa Shader or can it be done within the existing framework? Thank you.

Screen Shot 2020-06-24 at 11 19 20 am

cpinchuk avatar Jun 24 '20 01:06 cpinchuk

Did you do a view source on this example:

https://rawgit.com/cornerstonejs/cornerstone/master/example/falseColorMapping/index.html

On Tue, Jun 23, 2020 at 8:21 PM Costa P [email protected] wrote:

I have tried to apply colorMap to a greyscale PNG image and also tried other ways to apply false colour mapping, but the renderer fails miserably by calculating the pixel positions wrongly. Do I need to write my own WebGL RGBa Shader or can it be done within the existing framework? Thank you.

[image: Screen Shot 2020-06-24 at 11 19 20 am] https://user-images.githubusercontent.com/65931035/85485765-b58cfc80-b60c-11ea-89b3-051336ef8a9f.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cornerstonejs/cornerstone/issues/463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJVXWXDDCQ7NTVWYEVIP3TRYFIJXANCNFSM4OGGCVZA .

chafey avatar Jun 24 '20 12:06 chafey

I have it working

for that fixed the data population function in storedPixelDataToCanvasImageDataPseudocolorLUT

 while (storedPixelDataIndex < numPixels) {
      grayscale = grayscaleLut[pixelData[storedPixelDataIndex]];
      
     //index iteration fix 
     storedPixelDataIndex= storedPixelDataIndex+4;
      
      rgba = clut[grayscale];
      canvasImageDataData[canvasImageDataIndex++] = rgba[0];
      canvasImageDataData[canvasImageDataIndex++] = rgba[1];
      canvasImageDataData[canvasImageDataIndex++] = rgba[2];
      canvasImageDataData[canvasImageDataIndex++] = rgba[3];
    }

It was originally inserting the wrong pixel value every 4th. Example of greyscale image data converted with a colorMap (all the pixels had the same value for the experiment):

136,8,240,255, (correct) 136,8,240,255, (correct)   136,8,240,255, (correct),  255,252,250,255, (WRONG)
136,8,240,255, (correct)  136,8,240,255,(correct)    136,8,240,255,(correct)    255,252,250,255,(WRONG) ...

cpinchuk avatar Jun 29 '20 02:06 cpinchuk

Hi @cpinchuk can you please provide a link to a working example on this, I will be sooo thrilled if you've been able to get this working, because am unable to apply colormap to my images loaded with cornerstoneWebImageLoader. Thank you in advance!

andydoe19 avatar Jan 21 '22 13:01 andydoe19

This problem has not been fixed

David2k13 avatar Feb 28 '23 09:02 David2k13

这是来自QQ邮箱的假期自动回复邮件。 您好,邮件我已收到,我将在看到后第一时间给您回复。

No-Dream-No-Life avatar Feb 28 '23 09:02 No-Dream-No-Life