| |

VerySource

 Forgot password?
 Register
Search
View: 739|Reply: 1

Dicom image display problem, please master help, thank you very much!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-1-23 19:00:01
| Show all posts |Read mode
Hello everyone, my brother is now using dicom as a browser for image.
The various tag data in the dicom file are already readable. When displaying pixel information, I encountered a problem:
The images I am looking for are all OW-shaped.
Bits Allocated = 16
Bits Stored = 16
High Bit = 15
window center = 40
window width = 400
I put every two bytes of data into the last two bytes of an int. Then use the Toolkit class in java, the code is as follows:
            byte pixelData [] = new byte [fi.width * fi.height * 2];
        int imageData [] = new int [fi.width * fi.height];
        Ranch
        try {

        RandomAccessFile raf = new RandomAccessFile (directory + fileName, "r");
        raf.seek (fi.pixelData);
        System.out.println (fi.pixelData);
        raf.read (pixelData, 0, fi.width * fi.height * 2);
        }
        catch (Exception e)
        {
        e.printStackTrace ();
        }
        int currentLine = 0;
        int k = 0;
        for (int j = 0; j <fi.height; j ++)
        {
        Ranch
        for (int i = 0; i <fi.width; i ++)
        {
        int intdata = ((int) pixelData [2 * k]) << 8;
        intdata = intdata | (int) pixelData [2 * k + 1];
        imageData [fi.width * currentLine + i] = intdata;
        k ++;
        Ranch
        }
        currentLine ++;
        }
        image = Toolkit.getDefaultToolkit (). createImage (new MemoryImageSource (fi.width, fi.height, imageData, 0, fi.width));

But the resulting image is light yellow. Not a grayscale image. I think it must be that the intdata value of each pixel should be converted before it can be placed in the imageData array.
But I don't know how to switch or how to adjust the window width and window level.
Please troubleshoot your code to make it appear grayscale.
thank you very much!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-20 16:00:01
| Show all posts
All I can tell you to do is to adjust the window width and level.
It probably means this:
    In an area of ​​0-255 color range, choose a small area such as the range of 100-199, and use different algorithms to
Pixel information is mapped to the past (the simplest is the average value y=x/256*100+100; of course there are other non-linear methods).
    The window width refers to the range. The window level refers to the midpoint of the range. Window width=100, window level=49.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list