void ConvertJpeg2000(DicomDataSet ds) { DicomJpeg2000Options options = ds.DefaultJpeg2000Options; Console.WriteLine("JPEG 2000 Options:"); Console.WriteLine("DicomJpeg2000Options.UseColorTransform is : {0}", options.UseColorTransform); Console.WriteLine("DicomJpeg2000Options.DerivedQuantization is : {0}", options.DerivedQuantization); Console.WriteLine("DicomJpeg2000Options.TargetFileSize is : {0}", options.TargetFileSize); Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset is : {0}", options.ImageAreaHorizontalOffset); Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset is : {0}", options.ImageAreaVerticalOffset); Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth is : {0}", options.ReferenceTileWidth); Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight is : {0}", options.ReferenceTileHeight); Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset is : {0}", options.TileHorizontalOffset); Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset is : {0}", options.TileVerticalOffset); Console.WriteLine("DicomJpeg2000Options.DecompositionLevels is : {0}", options.DecompositionLevels); Console.WriteLine("DicomJpeg2000Options.ProgressingOrder is : {0}", options.ProgressingOrder); Console.WriteLine("DicomJpeg2000Options.CodeBlockWidth is : {0}", options.CodeBlockWidth); Console.WriteLine("DicomJpeg2000Options.CodeBlockHeight is : {0}", options.CodeBlockHeight); Console.WriteLine("DicomJpeg2000Options.UseSopMarker is : {0}", options.UseSopMarker); Console.WriteLine("DicomJpeg2000Options.UseEphMarker is : {0}", options.UseEphMarker); Console.WriteLine("DicomJpeg2000Options.RegionOfInterest is : {0}", options.RegionOfInterest); Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest is : {0}", options.UseRegionOfInterest); Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight is : {0}", options.RegionOfInterestWeight); Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle is : {0}", options.RegionOfInterestRectangle); options.CompressionControl = DicomJpeg2000CompressionControl.Ratio; options.CompressionRatio = 50; Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50"); //https://www.leadtools.com/help/leadtools/v19/dh/di/dicomdataset-setimage.html ds.Jpeg2000Options = options; ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None); }
private void MainForm_Load(object sender, EventArgs e) { DicomEngine.Startup(); DicomDataSet DummyDS = new DicomDataSet(); m_J2KOptions = DummyDS.Jpeg2000Options; AddUID(DicomUidType.ImplicitVRLittleEndian, "Implicit VR Little Endian (1.2.840.10008.1.2)"); AddUID(DicomUidType.ExplicitVRLittleEndian, "Explicit VR Little Endian (1.2.840.10008.1.2.1)"); AddUID(DicomUidType.ExplicitVRBigEndian, "Explicit VR Big Endian (1.2.840.10008.1.2.2)"); AddUID(DicomUidType.RLELossless, "RLE Lossless (1.2.840.10008.1.2.5)"); AddUID(DicomUidType.JPEGBaseline1, "JPEG Baseline (Process 1) (1.2.840.10008.1.2.4.50)"); AddUID(DicomUidType.JPEGExtended2_4, "JPEG Extended (Process 2 & 4) (1.2.840.10008.1.2.4.51)"); AddUID(DicomUidType.JPEGLosslessNonhier14, "JPEG Lossless, Non-Hierarchical (Process 14) (1.2.840.10008.1.2.4.57)"); AddUID(DicomUidType.JPEGLosslessNonhier14B, "JPEG Lossless, Non-Hierarchical,First-Order Prediction (1.2.840.10008.1.2.4.70)"); #if LEADTOOLS_V175_OR_LATER AddUID(DicomUidType.JPEGLSLossless, "JPEG-LS Lossless (1.2.840.10008.1.2.4.80)"); AddUID(DicomUidType.JPEGLSLossy, "JPEG-LS Lossy (1.2.840.10008.1.2.4.81)"); #endif AddUID(DicomUidType.JPEG2000LosslessOnly, "JPEG 2000 Lossless Only (1.2.840.10008.1.2.4.90)"); AddUID(DicomUidType.JPEG2000, "JPEG 2000 (1.2.840.10008.1.2.4.91)"); #if LEADTOOLS_V19_OR_LATER AddUID(DicomUidType.JPEG2000Part2MultiComponentImageCompressionLosslessOnly, "JPEG 2000 Part2, Multi Component Image Compression Lossless Only (1.2.840.10008.1.2.4.92)"); AddUID(DicomUidType.JPEG2000Part2MultiComponentImageCompression, "JPEG 2000 Part2, Multi Component Image Compression (1.2.840.10008.1.2.4.93)"); #endif cmbTransferSyntax.SelectedIndex = 0; J2kOptionsBtn.Enabled = false; txtQFactor.Enabled = false; txtQFactor.Text = "2"; }
private void btnOk_Click(object sender, EventArgs e) { DicomJpeg2000Options J2KOptions = m_DS.Jpeg2000Options; if (!FileSaveGetJ2KOptionsAdvanced(ref J2KOptions)) { return; } m_DS.Jpeg2000Options = J2KOptions; base.DialogResult = DialogResult.OK; base.Close(); }
private void btnDefault_Click(object sender, EventArgs e) { if (m_DS == null) { return; } DicomDataSet DummyDS = new DicomDataSet(); DicomJpeg2000Options J2KOptions = DummyDS.Jpeg2000Options; FileSaveFillJ2KOptionsAdvanced(ref J2KOptions); m_DS.Jpeg2000Options = J2KOptions; }
private void J2kOptionsBtn_Click(object sender, EventArgs e) { DicomDataSet DummyDS = new DicomDataSet(); J2kOptDlg J2KOptionsDlg = new J2kOptDlg(); DummyDS.Jpeg2000Options = m_J2KOptions; J2KOptionsDlg.m_DS = DummyDS; J2KOptionsDlg.m_nQFactor = Convert.ToInt16(txtQFactor.Text); string uid = ((MyTransferSyntax)cmbTransferSyntax.Items[cmbTransferSyntax.SelectedIndex]).szUID; if (uid == DicomUidType.JPEG2000LosslessOnly) { J2KOptionsDlg.m_bLossless = true; } J2KOptionsDlg.ShowDialog(); m_J2KOptions = DummyDS.Jpeg2000Options; }
protected void FileSaveFillJ2KOptionsAdvanced(ref DicomJpeg2000Options J2KOptions) { #if !LEADTOOLS_V19_OR_LATER chkSelectiveACBypass.Checked = J2KOptions.SelectiveAcBypass; chkResetContext.Checked = J2KOptions.ResetContextOnBoundaries; chkTermination.Checked = J2KOptions.TerminationOnEachPass; chkVerticallyCausal.Checked = J2KOptions.VerticallyCausalContext; chkPredictableTermination.Checked = J2KOptions.PredictableTermination; chkErrorResilience.Checked = J2KOptions.ErrorResilienceSymbol; #endif // #if !LEADTOOLS_V19_OR_LATER chkColorTransform.Checked = J2KOptions.UseColorTransform; chkDerivedQuantization.Checked = J2KOptions.DerivedQuantization; chkUseSOPMarker.Checked = J2KOptions.UseSopMarker; chkUseEPHMarker.Checked = J2KOptions.UseEphMarker; txtXOSIZ.Text = J2KOptions.ImageAreaHorizontalOffset.ToString(); txtYOSIZ.Text = J2KOptions.ImageAreaVerticalOffset.ToString(); txtXTSIZ.Text = J2KOptions.ReferenceTileWidth.ToString(); txtYTSIZ.Text = J2KOptions.ReferenceTileHeight.ToString(); txtXTOSIZ.Text = J2KOptions.TileHorizontalOffset.ToString(); txtYTOSIZ.Text = J2KOptions.TileVerticalOffset.ToString(); txtDecompLevel.Text = J2KOptions.DecompositionLevels.ToString(); #if !LEADTOOLS_V19_OR_LATER txtGuardBits.Text = J2KOptions.GuardBits.ToString(); txtMantissa.Text = J2KOptions.DerivedBaseMantissa.ToString(); txtExponent.Text = J2KOptions.DerivedBaseExponent.ToString(); txtCodeBlockWidth.Text = J2KOptions.CodeBlockWidth.ToString(); txtCodeBlockHeight.Text = J2KOptions.CodeBlockHeight.ToString(); #endif // #if !LEADTOOLS_V19_OR_LATER txtTargetSize.Text = J2KOptions.TargetFileSize.ToString(); txtQFactor.Text = m_nQFactor.ToString(); txtCompressionRatio.Text = J2KOptions.CompressionRatio.ToString(); switch (J2KOptions.CompressionControl) { case DicomJpeg2000CompressionControl.Ratio: cmbJ2kCompressionControl.SelectedIndex = 0; ShowHideCompressionFields(0); break; case DicomJpeg2000CompressionControl.TargetSize: cmbJ2kCompressionControl.SelectedIndex = 1; ShowHideCompressionFields(1); break; case DicomJpeg2000CompressionControl.QualityFactor: cmbJ2kCompressionControl.SelectedIndex = 2; ShowHideCompressionFields(2); break; } switch (J2KOptions.ProgressingOrder) { case DicomJpeg2000ProgressionsOrder.LayerResolutionComponentPosition: cmbJ2KProgressionOrder.SelectedIndex = 0; break; case DicomJpeg2000ProgressionsOrder.ResolutionLayerComponentPosition: cmbJ2KProgressionOrder.SelectedIndex = 1; break; case DicomJpeg2000ProgressionsOrder.ResolutionPositionComponentLayer: cmbJ2KProgressionOrder.SelectedIndex = 2; break; case DicomJpeg2000ProgressionsOrder.PositionComponentResolutionLayer: cmbJ2KProgressionOrder.SelectedIndex = 3; break; case DicomJpeg2000ProgressionsOrder.ComponentPositionResolutionLayer: cmbJ2KProgressionOrder.SelectedIndex = 4; break; } }
private bool FileSaveGetJ2KOptionsAdvanced(ref DicomJpeg2000Options J2KOptions) { int nValue = 0; if (GetEditInt(txtXOSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.ImageAreaHorizontalOffset = nValue; } else { return(false); } if (GetEditInt(txtYOSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.ImageAreaVerticalOffset = nValue; } else { return(false); } if (GetEditInt(txtXTSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.ReferenceTileWidth = nValue; } else { return(false); } if (GetEditInt(txtYTSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.ReferenceTileHeight = nValue; } else { return(false); } if (GetEditInt(txtXTOSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.TileHorizontalOffset = nValue; } else { return(false); } if (GetEditInt(txtYTOSIZ, ref nValue, 0, 0x3FFFFFFF)) { J2KOptions.TileVerticalOffset = nValue; } else { return(false); } if (GetEditInt(txtDecompLevel, ref nValue, 0, 32)) { J2KOptions.DecompositionLevels = nValue; } else { return(false); } #if !LEADTOOLS_V19_OR_LATER int xcb, ycb; int width; int height; if (GetEditInt(txtGuardBits, ref nValue, 0, 7)) { J2KOptions.GuardBits = nValue; } else { return(false); } if (GetEditInt(txtMantissa, ref nValue, 0, 2047)) { J2KOptions.DerivedBaseMantissa = nValue; } else { return(false); } if (GetEditInt(txtExponent, ref nValue, 0, 16)) { J2KOptions.DerivedBaseExponent = nValue; } else { return(false); } if (GetEditInt(txtCodeBlockWidth, ref nValue, 2, 64)) { J2KOptions.CodeBlockWidth = nValue; } else { return(false); } if (GetEditInt(txtCodeBlockHeight, ref nValue, 2, 64)) { J2KOptions.CodeBlockHeight = nValue; } else { return(false); } for (xcb = 0, width = J2KOptions.CodeBlockWidth; width > (1 << xcb); xcb++) { ; } for (ycb = 0, height = J2KOptions.CodeBlockHeight; height > (1 << ycb); ycb++) { ; } if ((width != (1 << xcb)) || (xcb < 2)) { SelectTextAndBeep(txtCodeBlockWidth); return(false); } if ((height != (1 << ycb)) || (ycb < 2) || ((xcb + ycb) > 12)) { SelectTextAndBeep(txtCodeBlockHeight); return(false); } #endif // #if !LEADTOOLS_V19_OR_LATER if (J2KOptions.TileHorizontalOffset > J2KOptions.ImageAreaHorizontalOffset) { SelectTextAndBeep(txtXTOSIZ); return(false); } if (J2KOptions.TileVerticalOffset > J2KOptions.ImageAreaVerticalOffset) { SelectTextAndBeep(txtYTOSIZ); return(false); } if (J2KOptions.ImageAreaHorizontalOffset > J2KOptions.TileHorizontalOffset + J2KOptions.ReferenceTileWidth) { SelectTextAndBeep(txtXOSIZ); return(false); } if (J2KOptions.ImageAreaVerticalOffset > J2KOptions.TileVerticalOffset + J2KOptions.ReferenceTileHeight) { SelectTextAndBeep(txtYOSIZ); return(false); } if (J2KOptions.ReferenceTileWidth < (uint)(2 << J2KOptions.DecompositionLevels) || J2KOptions.ReferenceTileHeight < (uint)(2 << J2KOptions.DecompositionLevels)) { SelectTextAndBeep(txtDecompLevel); return(false); } J2KOptions.UseColorTransform = chkColorTransform.Checked; J2KOptions.DerivedQuantization = chkDerivedQuantization.Checked; J2KOptions.UseSopMarker = chkUseSOPMarker.Checked; J2KOptions.UseEphMarker = chkUseEPHMarker.Checked; #if !LEADTOOLS_V19_OR_LATER J2KOptions.SelectiveAcBypass = chkSelectiveACBypass.Checked; J2KOptions.ResetContextOnBoundaries = chkResetContext.Checked; J2KOptions.TerminationOnEachPass = chkTermination.Checked; J2KOptions.VerticallyCausalContext = chkVerticallyCausal.Checked; J2KOptions.PredictableTermination = chkPredictableTermination.Checked; J2KOptions.ErrorResilienceSymbol = chkErrorResilience.Checked; #endif // #if !LEADTOOLS_V19_OR_LATER J2KOptions.CompressionControl = (DicomJpeg2000CompressionControl)cmbJ2kCompressionControl.SelectedIndex + 1; J2KOptions.ProgressingOrder = (DicomJpeg2000ProgressionsOrder)cmbJ2KProgressionOrder.SelectedIndex; try { J2KOptions.TargetFileSize = Convert.ToInt32(txtTargetSize.Text); } catch (Exception) { SelectTextAndBeep(txtTargetSize); return(false); } m_nQFactor = Convert.ToInt16(txtQFactor.Text); J2KOptions.CompressionRatio = Convert.ToSingle(txtCompressionRatio.Text); if (J2KOptions.CompressionRatio < 1.0) { J2KOptions.CompressionRatio = 15.0f; } return(true); }