概念解釋(網絡資料):
窗寬:
窗寬指CT圖像所顯示的CT 值范圍。在此CT值范圍內的組織結構按其密度高低從白到黑分為16 個灰階以供觀察對比。例如,窗寬選定為100 Hu ,則人眼可分辨的CT值為100 / 16 =6 . 25 Hu ,即2 種組織CT值相差在6 . 25Hu以上者即可為人眼所識別。因此,窗寬的寬窄直接影響圖像的清晰度與對比度。如果使用窄的窗寬,則顯示的CT 值范圍小,每一灰階代表的CT 值幅度小,對比度強,適於觀察密度接近的組織結構(如腦組織)。反之,如果使用寬的窗寬,則顯示的CT值范圍大,每一灰階代表的CT 值幅度大,則圖像對比度差,但密度均勻,適於觀察密度差別大的結構。
//實例化文件處理對象並打開文件 DicomFile dicomFile = DicomFile.Open(@"C:\101\1.dcm"); //獲取dicom圖像對象 DicomImage dicomImage = new DicomImage(dicomFile.Dataset); //獲取窗寬 Console.WriteLine(dicomImage.WindowWidth); //獲取窗位 Console.WriteLine(dicomImage.WindowCenter);
在鼠標操作上,按住鼠標左右移動是調整窗寬,上下移動是調整窗位,記錄鼠標按下時的位置和拖動坐標差,並重新設置影像的窗寬窗位:
//監聽鼠標按下事件 private void GridLine_MouseDown(object sender, MouseButtonEventArgs e) {try { SelectedBox(true); if (shapeManager.drawAction != DrawAction.None) { return; } //記錄鼠標位置 isMouseDown = true; StartPoint.X = e.GetPosition(GridLine).X; StartPoint.Y = e.GetPosition(GridLine).Y; if (DicomFile != null) { double? tagVal; DicomFile.Dataset.TryGetValue(DicomTag.WindowCenter, 0, out tagVal); if (tagVal != null) { //獲取原始調窗 datasetWinC = DicomFile.Dataset.GetValue<double>(DicomTag.WindowCenter, 0); datasetWinW = DicomFile.Dataset.GetValue<double>(DicomTag.WindowWidth, 0); //設置最后一次調窗 lastWindowCenter = DicomImage.WindowCenter - datasetWinC; lastWindowWidth = DicomImage.WindowWidth - datasetWinW; } else { lastWindowCenter = DicomImage.WindowCenter; lastWindowWidth = DicomImage.WindowWidth; } mouseDownScaleX = st.ScaleX; mouseDownScaleY = st.ScaleY; } } catch (Exception ex) { LogApi.WriteErrLog(ex); } }
看效果:
2.自定義調窗
可以使用鍵值對或其他數據格式來保存和加載自定義窗寬窗位,常用參考值如下:
1、胸部CT檢查時,肺窗縱膈窗窗寬、窗位分別是:
(1)肺窗WW1500—2000HU 、WL-450—-600HU
(2)縱膈窗WW250—350HU、WL30—50HU
2、骨窗、軟組織窗窗寬、窗位
(1)骨窗WW1000—1500HU、WL250—350HU
(2)軟組織窗WW300—500HU、WL40—60HU
3、窗寬和窗位設定
不同部位使用不同窗寬窗位,能較充分反映解剖內容和病灶影像表現,
頭顱:腦組織窗寬設定為80 Hu~100 Hu,窗位為30 Hu~40 Hu,
垂體及蝶鞍區病變窗寬宜設在200 Hu~250 Hu,窗位45 Hu~50 Hu,
腦出血患者可改變窗寬位80 Hu~140 Hu,窗位30 Hu~50 Hu,
腦梗死患者常用窄窗60 Hu,能提高病灶的檢出率,清楚顯示梗死及軟化灶,
頜面部眼眶窗寬定為150 Hu~250 Hu,窗位30 Hu~40 Hu,
觀察骨骼時窗寬150 Hu~2 000 Hu,窗位400 Hu~450 Hu,
喉頸部、鼻咽、咽喉部的窗寬和窗位常設在300 Hu~350 Hu和30 Hu~50 Hu,能滿足該部位的解剖和病灶顯示,
胸部:常規胸部CT檢查分別用縱隔窗及肺窗觀察,縱隔窗可觀察心臟、大血管的位置,
縱隔內淋巴結的大小,縱隔內腫塊及這些結構的比鄰關系,設定縱隔窗可用窗寬300 Hu~500 Hu,窗位30 Hu~50 Hu
根據此參考,我們可以設定一些默認的自定義調窗:
3.調窗的用作范圍
根據之前的文章:C#開發PACS醫學影像處理系統(八):單元格變換
當作用范圍是全部時,遍歷所有單元格和容器:
for (int i = 0; i < Main.Mdiview.Cells.Count; i++) for (int j = 0; j < Main.Mdiview.Cells[i].BoxList.Count; j++)
當作用范圍是序列時,只需遍歷當前單元格容器:
for (int i = 0; i < Cell.BoxList.Count; i++)
當作用范圍是圖像時,直接設置圖像:
//調整窗位 dicomImage.WindowCenter = 100; //調整窗寬 dicomImage.WindowWidth = 100;
部分代碼:
/// <summary> /// 變換窗寬窗位 /// </summary> /// <param name="X"></param> /// <param name="startX"></param> /// <param name="Y"></param> /// <param name="startY"></param> public void WinImage(double X, double startX, double Y, double startY, double myWidth = -999, double myCenter = -999) { double cVal = Y - startY; double wVal = X - startX; if (myWidth != -999 && myCenter != -999) { DicomImage.WindowCenter = myCenter; DicomImage.WindowWidth = myWidth; } else { DicomImage.WindowCenter = datasetWinC + lastWindowCenter + cVal; DicomImage.WindowWidth = datasetWinW + lastWindowWidth + wVal; } ImageHandler.SetImageScale(DicomImage, PalImgInfo); UpDateTag(); if (Main.WinRange == WindowRange.Series) { #region -----作用范圍:序列----- for (int i = 0; i < Cell.BoxList.Count; i++) { if (Cell.BoxList[i] != this) { Cell.BoxList[i].WinImage(DicomImage.WindowWidth, DicomImage.WindowCenter); } } #endregion } else if (Main.WinRange == WindowRange.All) { #region -----作用范圍:所有----- for (int i = 0; i < Main.Mdiview.Cells.Count; i++) { for (int j = 0; j < Main.Mdiview.Cells[i].BoxList.Count; j++) { if (Main.Mdiview.Cells[i].BoxList[j] != this) { Main.Mdiview.Cells[i].BoxList[j].WinImage(DicomImage.WindowWidth, DicomImage.WindowCenter); Main.Mdiview.Cells[i].MouseWindowCenter = DicomImage.WindowCenter; Main.Mdiview.Cells[i].MouseWindowWidth = DicomImage.WindowWidth; } } } #endregion } else { string key = Cell.studyInfo.CommonSeriesId + "|" + CurrentFrame; string value = DicomImage.WindowWidth + "|" + DicomImage.WindowCenter; if (PubVal.WinImageList.Keys.Contains(key)) { PubVal.WinImageList[key] = value; } else { PubVal.WinImageList.Add(key, value); } } Cell.MouseWindowCenter = DicomImage.WindowCenter; Cell.MouseWindowWidth = DicomImage.WindowWidth; }
效果: