Skip to content

Commit

Permalink
Added support for jpeg baseline 8bit encoded data. Added test. Relates
Browse files Browse the repository at this point in the history
to #61.
  • Loading branch information
ivmartel committed Sep 6, 2015
1 parent 9043144 commit 82ee957
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 41 deletions.
53 changes: 16 additions & 37 deletions src/dicom/dicomParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,25 +326,15 @@ dwv.dicom.splitGroupElementKey = function (key)
};

/**
* Tell if a given syntax is a JPEG baseline 8bit one.
* @method isJpegBaseline8bitTransferSyntax
* Tell if a given syntax is a JPEG baseline one.
* @method isJpegBaselineTransferSyntax
* @param {String} The transfer syntax to test.
* @returns {Boolean} True if a jpeg baseline 8bit syntax.
* @returns {Boolean} True if a jpeg baseline syntax.
*/
dwv.dicom.isJpegBaseline8bitTransferSyntax = function(syntax)
dwv.dicom.isJpegBaselineTransferSyntax = function(syntax)
{
return syntax === "1.2.840.10008.1.2.4.50";
};

/**
* Tell if a given syntax is a JPEG baseline 12bit one.
* @method isJpegBaseline8bitTransferSyntax
* @param {String} The transfer syntax to test.
* @returns {Boolean} True if a jpeg baseline 12bit syntax.
*/
dwv.dicom.isJpegBaseline12bitTransferSyntax = function(syntax)
{
return syntax === "1.2.840.10008.1.2.4.51";
return syntax === "1.2.840.10008.1.2.4.50" ||
syntax === "1.2.840.10008.1.2.4.51";
};

/**
Expand All @@ -356,8 +346,7 @@ dwv.dicom.isJpegBaseline12bitTransferSyntax = function(syntax)
dwv.dicom.isJpegNonSupportedTransferSyntax = function(syntax)
{
return ( syntax.match(/1.2.840.10008.1.2.4.5/) !== null &&
!dwv.dicom.isJpegBaseline8bitTransferSyntax() &&
!dwv.dicom.isJpegBaseline12bitTransferSyntax() &&
!dwv.dicom.isJpegBaselineTransferSyntax() &&
!dwv.dicom.isJpegLosslessTransferSyntax() ) ||
syntax.match(/1.2.840.10008.1.2.4.6/) !== null;
};
Expand Down Expand Up @@ -421,13 +410,9 @@ dwv.dicom.getTransferSyntaxName = function (syntax)
else if( syntax === "1.2.840.10008.1.2.2" ) {
name = "Big Endian Explicit";
}
// JPEG baseline 8bit
else if( dwv.dicom.isJpegBaseline8bitTransferSyntax(syntax) ) {
name = "JPEG Baseline 8bit";
}
// JPEG baseline 12bit
else if( dwv.dicom.isJpegBaseline12bitTransferSyntax(syntax) ) {
name = "JPEG Baseline 12bit";
// JPEG baseline
else if( dwv.dicom.isJpegBaselineTransferSyntax(syntax) ) {
name = "JPEG Baseline";
}
// JPEG Lossless
else if( dwv.dicom.isJpegLosslessTransferSyntax(syntax) ) {
Expand Down Expand Up @@ -790,8 +775,7 @@ dwv.dicom.DicomParser.prototype.parse = function(buffer)
{
var offset = 0;
var implicit = false;
var isJpegBaseline8bit = false;
var isJpegBaseline12bit = false;
var isJpegBaseline = false;
var isJpegLossless = false;
var isJpeg2000 = false;
// default readers
Expand Down Expand Up @@ -845,15 +829,10 @@ dwv.dicom.DicomParser.prototype.parse = function(buffer)
else if( syntax === "1.2.840.10008.1.2.2" ) {
dataReader = new dwv.dicom.DataReader(buffer,false);
}
// JPEG baseline 8bit
else if( dwv.dicom.isJpegBaseline8bitTransferSyntax(syntax) ) {
isJpegBaseline8bit = true;
throw new Error("Unsupported DICOM transfer syntax (JPEG basline 8bit): "+syntax);
}
// JPEG baseline 12bit
else if( dwv.dicom.isJpegBaseline12bitTransferSyntax(syntax) ) {
isJpegBaseline12bit = true;
console.log("JPEG Baseline 12bit compressed DICOM data: " + syntax);
// JPEG baseline
else if( dwv.dicom.isJpegBaselineTransferSyntax(syntax) ) {
isJpegBaseline = true;
console.log("JPEG Baseline compressed DICOM data: " + syntax);
}
// JPEG Lossless
else if( dwv.dicom.isJpegLosslessTransferSyntax(syntax) ) {
Expand Down Expand Up @@ -995,7 +974,7 @@ dwv.dicom.DicomParser.prototype.parse = function(buffer)
var decoded = decoder.decode();
this.pixelBuffer = new Uint16Array(decoded.buffer);
}
else if ( isJpegBaseline12bit ) {
else if ( isJpegBaseline ) {
decoder = new JpegImage();
decoder.parse( this.pixelBuffer );
this.pixelBuffer = decoder.getData(decoder.width,decoder.height);
Expand Down
16 changes: 12 additions & 4 deletions tests/pacs/data/index-jpeg.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,35 @@
// launch when page is loaded
$(document).ready( function()
{
dwv.addDataLine("dwv0", "nema-mr1_jply", {
dwv.addDataLine("dwv0", "leadtools-8BitsJpegLossyGrayScale", {
'origin': 'LeadTools',
'path': '8BitsJpegLossyGrayScale.zip',
't-syntax': '1.2.840.10008.1.2.4.50 (jpeg baseline)',
'modality': 'OT', 'photo': 'MONOCHROME2',
'bits': '8-8-7', 'pixel-vr': 'OW',
});
dwv.addDataLine("dwv1", "nema-mr1_jply", {
'origin': 'Nema WG04',
'path': 'compsamples_jpeg/IMAGES/JPLY/MR1_JPLY',
't-syntax': '1.2.840.10008.1.2.4.51 (jpeg baseline)',
'modality': 'MR', 'photo': 'MONOCHROME2',
'bits': '16-12-11', 'pixel-vr': 'OB',
});
dwv.addDataLine("dwv1", "nema-nm1_jply", {
dwv.addDataLine("dwv2", "nema-nm1_jply", {
'origin': 'Nema WG04',
'path': 'compsamples_jpeg/IMAGES/JPLY/NM1_JPLY',
't-syntax': '1.2.840.10008.1.2.4.51 (jpeg baseline)',
'modality': 'NM', 'photo': 'MONOCHROME2',
'bits': '16-12-11', 'pixel-vr': 'OB',
});
dwv.addDataLine("dwv2", "nema-ct1_jpll", {
dwv.addDataLine("dwv3", "nema-ct1_jpll", {
'origin': 'Nema WG04',
'path': 'compsamples_jpeg/IMAGES/JPLL/CT1_JPLL',
't-syntax': '1.2.840.10008.1.2.4.70 (jpeg lossless)',
'modality': 'CT', 'photo': 'MONOCHROME2',
'bits': '16-16-15', 'pixel-vr': 'OB',
});
dwv.addDataLine("dwv3", "nema-nm1_jpll", {
dwv.addDataLine("dwv4", "nema-nm1_jpll", {
'origin': 'Nema WG04',
'path': 'compsamples_jpeg/IMAGES/JPLL/NM1_JPLL',
't-syntax': '1.2.840.10008.1.2.4.70 (jpeg lossless)',
Expand All @@ -117,6 +124,7 @@
<p>Data sources:</p>
<ul>
<li>Nema WG04 (jpeg) <a href="ftp://medical.nema.org/MEDICAL/Dicom/DataSets/WG04/">dataSets</a></li>
<li>Leadtools datasets hosted at <a href="http://www.creatis.insa-lyon.fr/~jpr/PUBLIC/gdcm/gdcmSampleData/ColorDataSetLeadTool/">creatis</a></li>
</ul>
<p>The left image is created with DWV, the right one is a snapshot
generated using <a href="https://www.synedra.com">Synedra</a> View Personnal.</p>
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 82ee957

Please sign in to comment.