ImageProcessing Object

Summary

This class contains some of the medical image processing methods.

Syntax
TypeScript
JavaScript
function lt.Controls.Medical.ImageProcessing 
class lt.Controls.Medical.ImageProcessing() 
Remarks

All the methods are static and receive only image data and any other required parameters.

Example

ImageProcessing.ts
ImageProcessing.js
MedicalViewer_2DCell_Example.ts
MedicalViewer_2DCell_Example.js
import { MedicalViewer_2DCell_Example } from "../MedicalViewer_2DCell_Example"; 
 
export class ImageProcessing_Example { 
   private viewerExample; 
   private medicalViewer; 
   constructor() { 
      this.viewerExample = new MedicalViewer_2DCell_Example(this.run); 
   } 
 
   private run = (medicalViewer: lt.Controls.Medical.MedicalViewer) => { 
      this.medicalViewer = medicalViewer; 
 
 
      var cell: lt.Controls.Medical.Cell = this.medicalViewer.layout.cells.get_item(0); 
 
      var frame: lt.Controls.Medical.Frame = cell.frames.get_item(0); 
 
      var ip: lt.ImageProcessing = new lt.ImageProcessing(); 
      ip.set_jsFilePath(''); 
      ip.set_command("Dentin"); 
      ip.get_arguments()["MultiscaleEnhancement"] = "2000,-1,-1,-1,-1,'Gaussian'="; 
      ip.get_arguments()["GammaCorrect"] = "106="; 
      ip.get_arguments()["UnsharpMask"] = "150, 0,150,0"; 
 
      frame.imageProcessingList.add(ip); 
 
      // the user can do some window leveling after the effect is applied. 
      var cell: lt.Controls.Medical.Cell = this.medicalViewer.layout.cells.get_item(0); 
 
      var action: lt.Controls.Medical.WindowLevelAction = new lt.Controls.Medical.WindowLevelAction(0); 
 
      cell.setCommand(0, action); 
      cell.runCommand(0); 
   } 
} 
import { MedicalViewer_2DCell_Example } from "../MedicalViewer_2DCell_Example"; 
 
export class ImageProcessing_Example { 
    constructor() { 
        var _this = this; 
        this.run = function (medicalViewer) { 
            _this.medicalViewer = medicalViewer; 
            var cell = _this.medicalViewer.layout.cells.get_item(0); 
            var frame = cell.frames.get_item(0); 
            var ip = new lt.ImageProcessing(); 
            ip.set_jsFilePath(''); 
            ip.set_command("Dentin"); 
            ip.get_arguments()["MultiscaleEnhancement"] = "2000,-1,-1,-1,-1,'Gaussian'="; 
            ip.get_arguments()["GammaCorrect"] = "106="; 
            ip.get_arguments()["UnsharpMask"] = "150, 0,150,0"; 
            frame.imageProcessingList.add(ip); 
            // the user can do some window leveling after the effect is applied. 
            var cell = _this.medicalViewer.layout.cells.get_item(0); 
            var action = new lt.Controls.Medical.WindowLevelAction(); 
            cell.setCommand(0, action); 
            cell.runCommand(0); 
        }; 
        this.viewerExample = new MedicalViewer_2DCell_Example(this.run); 
    } 
} 
export class MedicalViewer_2DCell_Example { 
   // LEADTOOLS ImageViewer to be used with this example 
   protected medicalViewer: lt.Controls.Medical.MedicalViewer = null; 
   // Generic state value used by the examples 
   public timesClicked: number = 0; 
 
   constructor(callback?: (medicalViewer: lt.Controls.Medical.MedicalViewer) => void) { 
      // Set the LEADTOOLS license. Replace this with your actual license file 
      lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null); 
 
      // Create an image viewer inside the imageViewerDiv element 
      const imageViewerDiv: HTMLDivElement = <HTMLDivElement>document.getElementById("imageViewerDiv"); 
      const createOptions: lt.Controls.ImageViewerCreateOptions = new lt.Controls.ImageViewerCreateOptions(imageViewerDiv); 
 
 
 
      this.medicalViewer = new lt.Controls.Medical.MedicalViewer(imageViewerDiv, 1, 1); 
      this.medicalViewer.onSizeChanged(); 
 
      var cell = new lt.Controls.Medical.Cell(this.medicalViewer, this.medicalViewer.get_divId(), 1, 1); 
 
      // Set the show border to "true", to show a border around the cell.  
      cell.set_showFrameBorder(true); 
 
      // Add the cell to the viewer.   
      this.medicalViewer.layout.get_items().add(cell); 
 
      // [optional] Select the cell (it can also be selected by clicking on it.)  
      cell.set_selected(true); 
 
      // Now create a frame object which will hold the image inside the cell.  
      var cellFrame = new lt.Controls.Medical.Frame(cell); 
 
      // Add the frame to the cell class.  
      cell.get_frames().add(cellFrame); 
 
      // we are now going to to download an image from LEADTOOLS Medical Viewer demo web site. Change this to download images from your database.  
      var xhttp = new XMLHttpRequest(); 
      xhttp.onreadystatechange = function (data) { 
         if (this.readyState == 4 && this.status == 200) { 
            // here we got the authentication Code that we need to retrieve the images from LEADTOOLS database.  
            var authenticationCode = encodeURIComponent(this.responseText); 
 
 
            // the MRTI info that contains the image information, width, height, tiles....etc.  
            var mrtiInfo = new lt.Controls.Medical.MRTIImage(); 
 
            // The image dpi.  
            mrtiInfo.fullDpi = lt.LeadSizeD.create(150, 150); 
 
            // the tile size, recommended value is 256  
            mrtiInfo.tileSize = lt.LeadSizeD.create(256, 256); 
            mrtiInfo.frameIndex = 0; 
 
            // does this image support window level.  
            mrtiInfo.supportWindowLevel = true; 
 
            // different resolution for the image.  
            var resolutions = [{ "width": 2460, "height": 2970 }, { "width": 1230, "height": 1485 }, { "width": 615, "height": 742 }, { "width": 307, "height": 371 }, { "width": 153, "height": 185 }, { "width": 76, "height": 92 }]; 
            mrtiInfo.resolutions = []; 
            for (var i = 0; i < resolutions.length; i++) { 
               mrtiInfo.resolutions[i] = lt.LeadSizeD.create(resolutions[i].width, resolutions[i].height); 
            } 
 
            // the image width and height.  
            cellFrame.set_width(mrtiInfo.resolutions[0].width); 
            cellFrame.set_height(mrtiInfo.resolutions[0].height); 
 
            // the image full size.  
            mrtiInfo.fullSize = lt.LeadSizeD.create(cellFrame.get_width(), cellFrame.get_height()); 
 
            // now we need the image URL,  
            var imageUri = "https://medicaldemos.leadtools.com/MedicalViewerServiceAsp22/api/retrieve"; 
            imageUri += "/GetImageTile?auth="; 
            imageUri += authenticationCode; 
            // this the image instance UID, change this if you want to retrieve anything else.  
            imageUri += "&instance=1.3.251.1146.3891.2001006.1752215.5"; 
            mrtiInfo.imageUri = imageUri; 
 
            // set this info to the cell frame.  
            cellFrame.mrtiInfo = mrtiInfo; 
 
 
            // now we need to set the information for the image so we can do window level.  
            var imageInfo = new lt.Controls.Medical.DICOMImageInformation(); 
 
 
            // set the image width and height.  
            imageInfo.width = 2460; 
            imageInfo.height = 2970; 
 
            // bits per pixel for the image  
            imageInfo.bitsPerPixel = 16; 
            // low and high bit.  
            imageInfo.lowBit = 0; 
            imageInfo.highBit = 11; 
 
            // other information, setting some of them to zero means that the toolkit will try and calculate it by itself,  
            // but you can always get those values from the DicomDataSet.  
            imageInfo.autoScaleIntercept = 0; 
            imageInfo.autoScaleSlope = 1; 
            imageInfo.minValue = 0; 
            imageInfo.maxValue = 0; 
            imageInfo.windowWidth = 0; 
            imageInfo.windowCenter = 0; 
            imageInfo.signed = false; 
            imageInfo.photometricInterpretation = 'MONOCHROME1'; 
            imageInfo.firstStoredPixelValueMapped = 0; 
 
            // set these information to the frame.  
 
            cellFrame.set_information(imageInfo); 
         } 
      }; 
 
      // We are trying to get an image from the LEADTOOLS database, we need to login and get the authentication code.  
      xhttp.open("POST", "https://medicaldemos.leadtools.com/MedicalViewerServiceAsp22/api/auth/AuthenticateUser", true); 
      xhttp.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); 
      // we log in as a 'guest', after calling the below line, we will receive the authentication code sent via 'onreadystatechange' above.  
      xhttp.send(JSON.stringify({ userName: 'guest', password: 'guest', userData: '' })); 
 
      // this.imageViewer = new lt.Controls.ImageViewer(createOptions); 
      // this.imageViewer.viewVerticalAlignment = lt.Controls.ControlAlignment.center; 
      // this.imageViewer.viewHorizontalAlignment = lt.Controls.ControlAlignment.center; 
      // this.imageViewer.autoCreateCanvas = true; 
 
      // // Add Pan/Zoom interactive mode 
      // // Click and drag to pan, CTRL-Click and drag to zoom in and out 
      // this.imageViewer.interactiveModes.add(new lt.Controls.ImageViewerPanZoomInteractiveMode()); 
 
      // // Load an image 
      // this.imageViewer.imageUrl = "https://demo.leadtools.com/images/jpeg/cannon.jpg"; 
 
      // this.imageViewer.zoom(lt.Controls.ControlSizeMode.fit, .9, this.imageViewer.defaultZoomOrigin); 
 
      const exampleButton = document.getElementById("exampleButton"); 
      exampleButton.addEventListener("click", () => { 
         this.timesClicked++; 
         // Run the example 
         if (callback) 
            callback(this.medicalViewer); 
      }); 
   } 
} 
export class MedicalViewer_2DCell_Example { 
    constructor(callback) { 
        // LEADTOOLS ImageViewer to be used with this example 
        this.medicalViewer = null; 
        // Generic state value used by the examples 
        this.timesClicked = 0; 
        // Set the LEADTOOLS license. Replace this with your actual license file 
        lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null); 
        // Create an image viewer inside the imageViewerDiv element 
        const imageViewerDiv = document.getElementById("imageViewerDiv"); 
        const createOptions = new lt.Controls.ImageViewerCreateOptions(imageViewerDiv); 
        this.medicalViewer = new lt.Controls.Medical.MedicalViewer(imageViewerDiv, 1, 1); 
        this.medicalViewer.onSizeChanged(); 
        var cell = new lt.Controls.Medical.Cell(this.medicalViewer, this.medicalViewer.get_divId(), 1, 1); 
        // Set the show border to "true", to show a border around the cell.  
        cell.set_showFrameBorder(true); 
        // Add the cell to the viewer.   
        this.medicalViewer.layout.get_items().add(cell); 
        // [optional] Select the cell (it can also be selected by clicking on it.)  
        cell.set_selected(true); 
        // Now create a frame object which will hold the image inside the cell.  
        var cellFrame = new lt.Controls.Medical.Frame(cell); 
        // Add the frame to the cell class.  
        cell.get_frames().add(cellFrame); 
        // we are now going to to download an image from LEADTOOLS medical viewer demo web site, you need to change this to download images from your database.  
        var xhttp = new XMLHttpRequest(); 
        xhttp.onreadystatechange = function (data) { 
            if (this.readyState == 4 && this.status == 200) { 
                // here we got the authentication Code that we need to retrieve the images from leadtools database.  
                var authenticationCode = encodeURIComponent(this.responseText); 
                // now, this is the MRTI info that contains the image information, width, height, tiles....etc.  
                var mrtiInfo = new lt.Controls.Medical.MRTIImage(); 
                // The image dpi.  
                mrtiInfo.fullDpi = lt.LeadSizeD.create(150, 150); 
                // the tile size, recommended value is 256  
                mrtiInfo.tileSize = lt.LeadSizeD.create(256, 256); 
                mrtiInfo.frameIndex = 0; 
                // does this image support window level.  
                mrtiInfo.supportWindowLevel = true; 
                // different resolution for the image.  
                var resolutions = [{ "width": 2460, "height": 2970 }, { "width": 1230, "height": 1485 }, { "width": 615, "height": 742 }, { "width": 307, "height": 371 }, { "width": 153, "height": 185 }, { "width": 76, "height": 92 }]; 
                mrtiInfo.resolutions = []; 
                for (var i = 0; i < resolutions.length; i++) { 
                    mrtiInfo.resolutions[i] = lt.LeadSizeD.create(resolutions[i].width, resolutions[i].height); 
                } 
                // the image width and height.  
                cellFrame.set_width(mrtiInfo.resolutions[0].width); 
                cellFrame.set_height(mrtiInfo.resolutions[0].height); 
                // the image full size.  
                mrtiInfo.fullSize = lt.LeadSizeD.create(cellFrame.get_width(), cellFrame.get_height()); 
                // now we need the image URL,  
                var imageUri = "https://medicaldemos.leadtools.com/MedicalViewerServiceAsp22/api/retrieve"; 
                imageUri += "/GetImageTile?auth="; 
                imageUri += authenticationCode; 
                // this the image instance UID, change this if you want to retrieve anything else.  
                imageUri += "&instance=1.3.251.1146.3891.2001006.1752215.5"; 
                mrtiInfo.imageUri = imageUri; 
                // set this info to the cell frame.  
                cellFrame.mrtiInfo = mrtiInfo; 
                // now we need to set the information for the image so we can do window level.  
                var imageInfo = new lt.Controls.Medical.DICOMImageInformation(); 
                // set the image width and height.  
                imageInfo.width = 2460; 
                imageInfo.height = 2970; 
                // bits per pixel for the image  
                imageInfo.bitsPerPixel = 16; 
                // low and high bit.  
                imageInfo.lowBit = 0; 
                imageInfo.highBit = 11; 
                // other information, setting some of them to zero means that the toolkit will try and calculate it by itself, but you can always get those values from the DicomDataSet.  
                imageInfo.modalityIntercept = 0; 
                imageInfo.modalitySlope = 1; 
                imageInfo.minValue = 0; 
                imageInfo.maxValue = 0; 
                imageInfo.windowWidth = 0; 
                imageInfo.windowCenter = 0; 
                imageInfo.signed = false; 
                imageInfo.photometricInterpretation = 'MONOCHROME1'; 
                imageInfo.firstStoredPixelValueMapped = 0; 
                // set these information to the frame.  
                cellFrame.set_information(imageInfo); 
            } 
        }; 
        // We are trying to get an image from the LEADTOOLS database, we need to login and get the authentication code.  
        xhttp.open("POST", "https://medicaldemos.leadtools.com/MedicalViewerServiceAsp22/api/auth/AuthenticateUser", true); 
        xhttp.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); 
        // we log in as a 'guest', after calling the below line, we will receive the authentication code sent via 'onreadystatechange' above.  
        xhttp.send(JSON.stringify({ userName: 'guest', password: 'guest', userData: '' })); 
        // this.imageViewer = new lt.Controls.ImageViewer(createOptions); 
        // this.imageViewer.viewVerticalAlignment = lt.Controls.ControlAlignment.center; 
        // this.imageViewer.viewHorizontalAlignment = lt.Controls.ControlAlignment.center; 
        // this.imageViewer.autoCreateCanvas = true; 
        // // Add Pan/Zoom interactive mode 
        // // Click and drag to pan, CTRL-Click and drag to zoom in and out 
        // this.imageViewer.interactiveModes.add(new lt.Controls.ImageViewerPanZoomInteractiveMode()); 
        // // Load an image 
        // this.imageViewer.imageUrl = "https://demo.leadtools.com/images/jpeg/cannon.jpg"; 
        // this.imageViewer.zoom(lt.Controls.ControlSizeMode.fit, .9, this.imageViewer.defaultZoomOrigin); 
        const exampleButton = document.getElementById("exampleButton"); 
        exampleButton.addEventListener("click", () => { 
            this.timesClicked++; 
            // Run the example 
            if (callback) 
                callback(this.medicalViewer); 
        }); 
    } 
} 
Requirements

Target Platforms

Help Version 22.0.2023.2.14
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls.Medical Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.