Loading ...
Sorry, an error occurred while loading the content.

Re: Window Level

Expand Messages
  • jimirrer
    I just did something very similar recently. Use the java.awt.image.RescaleOp which can do a multiply and add to each pixel and put it into a Swing label:
    Message 1 of 5 , Dec 19, 2011
    View Source
    • 0 Attachment
      I just did something very similar recently. Use the java.awt.image.RescaleOp
      which can do a multiply and add to each pixel and put it into a Swing label:

      BufferedImage image = ConsumerFormatImageMaker.makeEightBitImage(attributeList, 0);
      float contrast = 10.0;
      float offset = 50.0;
      RescaleOp rescale = new RescaleOp(contrast, offset, null);
      BufferedImage transformedImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
      rescale.filter(image, transformedImage);
      ImageIcon imageIcon = new ImageIcon(transformedImage);
      JLabel label = new JLabel(imageIcon);

      You need to do basically the same thing but the math is a little different. Use BufferedImage.getRaster to
      get the raw pixels, find min and max values, then translate with the proper scale and offset instead of the
      10 and 50 values shown above.

      Good luck,

      - Jim





      --- In pixelmed_dicom@yahoogroups.com, "rogerdelaforet" <rogerdelaforet@...> wrote:
      >
      > Hello
      >
      > I have a question: How to just perform a simple window-level on a BufferedImage created from SourceImage.
      >
      > I would do so by indicating the min and max
      >
      > I found your library a few days ago. Congratulations for this great work
      > Thank you in advance. (and sorry if i made some errors in my english)
      >
    • rogerdelaforet
      Ok, thank you for your answer. It looks to do what I want, now I would have to calculate the correct values I do not know what is contrast and offset I
      Message 2 of 5 , Dec 20, 2011
      View Source
      • 0 Attachment
        Ok, thank you for your answer.

        It looks to do what I want, now I would have to calculate the correct values

        I do not know what is "contrast" and "offset"

        I want to display only the pixels between two values ​​that are defined as Hounsfield.

        Thanks

        --- In pixelmed_dicom@yahoogroups.com, "jimirrer" <irrer@...> wrote:
        >
        >
        >
        > I just did something very similar recently. Use the java.awt.image.RescaleOp
        > which can do a multiply and add to each pixel and put it into a Swing label:
        >
        > BufferedImage image = ConsumerFormatImageMaker.makeEightBitImage(attributeList, 0);
        > float contrast = 10.0;
        > float offset = 50.0;
        > RescaleOp rescale = new RescaleOp(contrast, offset, null);
        > BufferedImage transformedImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
        > rescale.filter(image, transformedImage);
        > ImageIcon imageIcon = new ImageIcon(transformedImage);
        > JLabel label = new JLabel(imageIcon);
        >
        > You need to do basically the same thing but the math is a little different. Use BufferedImage.getRaster to
        > get the raw pixels, find min and max values, then translate with the proper scale and offset instead of the
        > 10 and 50 values shown above.
        >
        > Good luck,
        >
        > - Jim
        >
        >
        >
        >
        >
        > --- In pixelmed_dicom@yahoogroups.com, "rogerdelaforet" <rogerdelaforet@> wrote:
        > >
        > > Hello
        > >
        > > I have a question: How to just perform a simple window-level on a BufferedImage created from SourceImage.
        > >
        > > I would do so by indicating the min and max
        > >
        > > I found your library a few days ago. Congratulations for this great work
        > > Thank you in advance. (and sorry if i made some errors in my english)
        > >
        >
      • jimirrer
        I use the values as contrast and offset, but they are actually a linear operation on the value of each pixel, as in: new_value = old_value * contrast + offset
        Message 3 of 5 , Dec 20, 2011
        View Source
        • 0 Attachment
          I use the values as contrast and offset, but they are actually a linear operation on the value of each pixel, as in:

          new_value = old_value * contrast + offset

          http://docs.oracle.com/javase/6/docs/api/java/awt/image/RescaleOp.html#RescaleOp(float, float, java.awt.RenderingHints)

          - Jim

          --- In pixelmed_dicom@yahoogroups.com, "rogerdelaforet" <rogerdelaforet@...> wrote:
          >
          > Ok, thank you for your answer.
          >
          > It looks to do what I want, now I would have to calculate the correct values
          >
          > I do not know what is "contrast" and "offset"
          >
          > I want to display only the pixels between two values ​​that are defined as Hounsfield.
          >
          > Thanks
          >
          > --- In pixelmed_dicom@yahoogroups.com, "jimirrer" <irrer@> wrote:
          > >
          > >
          > >
          > > I just did something very similar recently. Use the java.awt.image.RescaleOp
          > > which can do a multiply and add to each pixel and put it into a Swing label:
          > >
          > > BufferedImage image = ConsumerFormatImageMaker.makeEightBitImage(attributeList, 0);
          > > float contrast = 10.0;
          > > float offset = 50.0;
          > > RescaleOp rescale = new RescaleOp(contrast, offset, null);
          > > BufferedImage transformedImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
          > > rescale.filter(image, transformedImage);
          > > ImageIcon imageIcon = new ImageIcon(transformedImage);
          > > JLabel label = new JLabel(imageIcon);
          > >
          > > You need to do basically the same thing but the math is a little different. Use BufferedImage.getRaster to
          > > get the raw pixels, find min and max values, then translate with the proper scale and offset instead of the
          > > 10 and 50 values shown above.
          > >
          > > Good luck,
          > >
          > > - Jim
          > >
          > >
          > >
          > >
          > >
          > > --- In pixelmed_dicom@yahoogroups.com, "rogerdelaforet" <rogerdelaforet@> wrote:
          > > >
          > > > Hello
          > > >
          > > > I have a question: How to just perform a simple window-level on a BufferedImage created from SourceImage.
          > > >
          > > > I would do so by indicating the min and max
          > > >
          > > > I found your library a few days ago. Congratulations for this great work
          > > > Thank you in advance. (and sorry if i made some errors in my english)
          > > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.