Giter Club home page Giter Club logo

Comments (10)

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Correction: I had not seen how to install the jpeg plugin, am trying that now. Will close if that fixes!

from pylibjpeg.

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Closing, that fixed it. Thank you.

from pylibjpeg.

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Actually, although I do get a pixel array without errors, now, when I try to write the image it still has mostly green in it. Please advise?

from pylibjpeg.

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Output attached.
1 3 6 1 4 1 30071 6 17171705996 5259616659525711

from pylibjpeg.

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Ok more info: I tried forcing this to be interpeted by PIL as RGB and then I can write this out to look correct. My code was assuming however that this should be written out as "YCbCr" since the Photometric Interpretation is YBR_FULL_422. Should I be checking other DICOM attributes to determine whether or not to use "YCbCr"?

from pylibjpeg.

jacksonofalltrades avatar jacksonofalltrades commented on August 17, 2024

Correct image attached forcing RGB image mode when writing out.
test

from pylibjpeg.

scaramallion avatar scaramallion commented on August 17, 2024

pydicom returns the Pixel Data as-is, so if the Photometric Interpretation is YBR_FULL_422 then you get back a YCbCr image, if it's RGB you get back an RGB image. To convert to RGB you can use the pydicom.pixel_data_handlers.util.convert_color_space() function.

from pylibjpeg.

scaramallion avatar scaramallion commented on August 17, 2024

Ah, I misunderstood. It should be displayed as YCbCr but its coming back as RGB.

Let me take a look

from pylibjpeg.

scaramallion avatar scaramallion commented on August 17, 2024

OK, looking at the data inside the JPG file, the SOF0 marker has three components with the component IDs: 'R', 'G', and 'B'. This is pretty standard when data has been encoded in the RGB colourspace rather than YCbCr, particularly images from Adobe like this one. I think in this case the Photometric Interpretation should be 'RGB'.

A quick googling shows this page has a bit more info.

from pylibjpeg.

scaramallion avatar scaramallion commented on August 17, 2024

For reference, heres the JPEG info:

=================== SOI marker at offset 0 ====================

------------- APP14 marker at offset 2, length 16 -------------
Adobe v100:
  64 00 00 00 00 00

------------- DQT marker at offset 18, length 69 --------------
Table destination ID: 0
Table precision: 0 (8-bit)
Quantization table:
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1
   1   1   1   1   1   1   1   1

------------- SOF0 marker at offset 87, length 19 -------------
Baseline sequential DCT
Sample size (px): 800 x 600
Sample precision (bits): 8
Number of component images: 3
  Component ID: R
    Horizontal sampling factor: 1
    Vertical sampling factor: 1
    Quantization table destination: 0
  Component ID: G
    Horizontal sampling factor: 1
    Vertical sampling factor: 1
    Quantization table destination: 0
  Component ID: B
    Horizontal sampling factor: 1
    Vertical sampling factor: 1
    Quantization table destination: 0

------------- DHT marker at offset 106, length 33 -------------
Lossless/DC Huffman, table ID: 0
   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
  01 00 01 04 03 01 01 01 00 00 00 00 00 00 00 00 : # codes
  00                                              : L = 1
  06                                              : L = 3
  04 05 07 08                                     : L = 4
  02 03 09                                        : L = 5
  0a                                              : L = 6
  01                                              : L = 7
  0b                                              : L = 8

------------ DHT marker at offset 139, length 112 -------------
AC Huffman, table ID: 0
   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
  00 01 03 03 03 02 03 04 04 08 0a 08 03 00 00 27 : # codes
  01                                              : L = 2
  02 03 04                                        : L = 3
  05 06 11                                        : L = 4
  00 07 12                                        : L = 5
  08 21                                           : L = 6
  13 14 31                                        : L = 7
  09 15 22 41                                     : L = 8
  32 51 52 61                                     : L = 9
  16 23 54 91 92 a1 a2 d1                         : L = 10
  17 18 33 42 62 97 a3 d3 d6 e1                   : L = 11
  0a 24 57 71 93 98 d2 d7                         : L = 12
  43 53 81                                        : L = 13
  19 25 56 72 34 55 82 b2 c1 f0 26 27 58 59 73 75 : L = 16
  83 63 66 b1 35 36 39 44 64 c2 c3 c4 1a 28 37 38 : L = 16
  74 76 88 b4 b6 b7 b8                            : L = 16

------------- SOS marker at offset 251, length 14 -------------
Number of image components: 3
  Component: R, DC table: 0, AC table: 0
  Component: G, DC table: 0, AC table: 0
  Component: B, DC table: 0, AC table: 0
Spectral selectors start-end: 0-63
Successive approximation bit high-low: 0-0

................... ENC marker at offset 263...................

399085 bytes of entropy-coded data

from pylibjpeg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.