public VectorStringEnumerator(VectorString collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; }
public Provider(string fileName, VectorString propertiesArray) : this(FiftyOneDegreesTrieV3PINVOKE.new_Provider__SWIG_2(fileName, VectorString.getCPtr(propertiesArray)), true) { if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); } }
static void Main(string[] args) { try { if (args.Length < 2) { Console.WriteLine("Usage: DicomSeriesReader <input_directory> <output_file>"); return; } Console.WriteLine("Reading Dicom directory: " + args[0]); ImageSeriesReader reader = new ImageSeriesReader(); VectorString dicom_names = ImageSeriesReader.GetGDCMSeriesFileNames(args[0]); reader.SetFileNames(dicom_names); Image image = reader.Execute(); VectorUInt32 size = image.GetSize(); Console.WriteLine("Image size: " + size[0] + " " + size[1] + " " + size[2]); Console.WriteLine("Writing image: " + args[1]); ImageFileWriter writer = new ImageFileWriter(); writer.SetFileName(args[1]); writer.Execute(image); if (Environment.GetEnvironmentVariable("SITK_NOSHOW") == null) { SimpleITK.Show(image, "Dicom Series"); } } catch (Exception ex) { Console.WriteLine("Usage: DicomSeriesReader <input_directory> <output_file>"); Console.WriteLine(ex); } }
public VectorString(VectorString other) : this(PapillonPINVOKE.new_VectorString__SWIG_1(VectorString.getCPtr(other)), true) { if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } }
public static void Main() { VectorPairIntString vpis = new VectorPairIntString(); vpis.Add(new PairIntString(123, "one hundred and twenty three")); VectorString vs = new VectorString(); vs.Add("hi"); PairIntVectorString pivs = new PairIntVectorString(456, vs); if (pivs.second[0] != "hi") throw new ApplicationException("PairIntVectorString"); VectorVectorString vvs = new VectorVectorString(); vvs.Add(vs); PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4")); if (pipis.first != 12) throw new ApplicationException("PairIntPairIntString"); PairDoubleString pds = new PairDoubleString(12.34, "okay"); VectorPairDoubleString vpds = new VectorPairDoubleString(); vpds.Add(pds); // Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method if (!vpds.Contains(pds)) throw new ApplicationException("VectorPairDoubleString"); }
public VectorString(VectorString other) : this(FiftyOneDegreesPatternV3PINVOKE.new_VectorString__SWIG_1(VectorString.getCPtr(other)), true) { if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); } }
public Provider(string fileName, VectorString propertiesArray, int cacheSize, int poolSize) : this(FiftyOneDegreesPatternV3PINVOKE.new_Provider__SWIG_4(fileName, VectorString.getCPtr(propertiesArray), cacheSize, poolSize), true) { if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); } }
public void SetRange(int index, VectorString values) { FiftyOneDegreesPatternV3PINVOKE.VectorString_SetRange(swigCPtr, index, VectorString.getCPtr(values)); if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); } }
public void AddRange(VectorString values) { FiftyOneDegreesTrieV3PINVOKE.VectorString_AddRange(swigCPtr, VectorString.getCPtr(values)); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); } }
public void SetRange(int index, VectorString values) { PapillonPINVOKE.VectorString_SetRange(swigCPtr, index, VectorString.getCPtr(values)); if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } }
public VectorString getValues(SWIGTYPE_p_std__string propertyName) { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Match_getValues__SWIG_1(swigCPtr, SWIGTYPE_p_std__string.getCPtr(propertyName)), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public VectorString getHttpHeaders() { VectorString ret = new VectorString(FiftyOneDegreesPatternV3PINVOKE.Provider_getHttpHeaders(swigCPtr), true); if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public VectorString getValues(int propertyIndex) { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Match_getValues__SWIG_2(swigCPtr, propertyIndex), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public VectorString getAvailableProperties() { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Provider_getAvailableProperties(swigCPtr), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public VectorString getValues(string propertyName) { VectorString ret = new VectorString(FiftyOneDegreesPatternV3PINVOKE.Match_getValues__SWIG_0(swigCPtr, propertyName), true); if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) { throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
// Snippet Start /// <summary> /// Runs the program. /// </summary> /// <param name="fileName"> /// Path to the 51Degrees device data file. /// </param> /// <param name="inputFile"> /// Path to the input data file containing User-Agents to process. /// </param> public static void Run(string fileName, string inputFile) { int i, j; // Where to store processed User-Agents. string outputFile = "OfflineProcessingOutput.csv"; string userAgent; Match match; string propertiesList = "IsMobile,PlatformName,PlatformVersion"; Provider provider = new Provider(fileName, propertiesList); // Fetched available properties as a VectorString. VectorString properties = provider.getAvailableProperties(); // Opens input and output files. StreamReader fin = new StreamReader(inputFile); StreamWriter fout = new StreamWriter(outputFile); Console.WriteLine("Starting Offline Processing Example."); // Print CSV headers to output file. fout.Write("User-Agent"); for (i = 0; i < properties.Count(); i++) { fout.Write("|" + properties[i]); } fout.Write("\n"); // Carries out match for first 20 User-Agents and prints results to // output file. for (i = 1; i < 20; i++) { userAgent = fin.ReadLine(); using (match = provider.getMatch(userAgent)) { Assert.IsNotNull(match); fout.Write(userAgent); for (j = 0; j < properties.Count(); j++) { fout.Write("|" + match.getValue(properties[j])); } fout.Write("\n"); } } fin.Close(); fout.Close(); Console.WriteLine("Output Written to " + outputFile); // At the end of the program dispose of the data file to // deallocate memory. provider.Dispose(); }
public VectorString GetRange(int index, int count) { global::System.IntPtr cPtr = PapillonPINVOKE.VectorString_GetRange(swigCPtr, index, count); VectorString ret = (cPtr == global::System.IntPtr.Zero) ? null : new VectorString(cPtr, true); if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static VectorString Repeat(string value, int count) { global::System.IntPtr cPtr = PapillonPINVOKE.VectorString_Repeat(value, count); VectorString ret = (cPtr == global::System.IntPtr.Zero) ? null : new VectorString(cPtr, true); if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/*! Load the entire series (i.e. the entire volume). * Unlike loadImageData(), this function does not create a colors array or texture. To * access volume data, simply get the image (DICOM.image) and read pixel values from it. */ private void loadVolumeData() { // Get all file names for the series: VectorString fileNames = seriesInfo.filenames; // Create a reader which will read the whole series: ImageSeriesReader reader = new ImageSeriesReader(); reader.SetFileNames(fileNames); // Load the entire image into a series: Image image = reader.Execute(); // Make the loaded image accessable from elsewhere: this.image = image; }
public static void Main() { VectorPairIntString vpis = new VectorPairIntString(); vpis.Add(new PairIntString(123, "one hundred and twenty three")); VectorString vs = new VectorString(); vs.Add("hi"); PairIntVectorString pivs = new PairIntVectorString(456, vs); if (pivs.second[0] != "hi") { throw new ApplicationException("PairIntVectorString"); } VectorVectorString vvs = new VectorVectorString(); vvs.Add(vs); PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4")); if (pipis.first != 12) { throw new ApplicationException("PairIntPairIntString"); } PairDoubleString pds = new PairDoubleString(12.34, "okay"); VectorPairDoubleString vpds = new VectorPairDoubleString(); vpds.Add(pds); // Check alaqil_STD_VECTOR_ENHANCED macro - it provides the Contains method if (!vpds.Contains(pds)) { throw new ApplicationException("VectorPairDoubleString"); } }
/*! Searches the directoryToLoad for DICOMs. Called in thread!*/ public void parseDirectory(object sender, DoWorkEventArgs e) { // Parse the directory and return the seriesUIDs of all the DICOM series: try { availableSeries.Clear(); Debug.Log("[DICOM] Searching directory: " + directoryToLoad); VectorString series = ImageSeriesReader.GetGDCMSeriesIDs(directoryToLoad); if (series.Count > 0) { foreach (string s in series) { DICOMSeries info = new DICOMSeries(directoryToLoad, s); availableSeries.Add(info); } } // Debug log: string str = "[DICOM] Found " + series.Count + " series."; Debug.Log(str); } catch (System.Exception err) { Debug.LogError("Error while trying to parse DICOM directory: " + err.Message); } }
public VectorString getValues(SWIGTYPE_p_std__string propertyName) { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Match_getValues__SWIG_1(swigCPtr, SWIGTYPE_p_std__string.getCPtr(propertyName)), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VectorString obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public Provider(string fileName, VectorString propertiesArray, int cacheSize, int poolSize) : this(FiftyOneDegreesPatternV3PINVOKE.new_Provider__SWIG_4(fileName, VectorString.getCPtr(propertiesArray), cacheSize, poolSize), true) { if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); }
/*! Loads a single file and creates an array of colors from the pixels. * The array of colors can later be used to generate a texture, see getTexture2D() */ private void loadImageData(int slice) { VectorString fileNames = seriesInfo.filenames; // Read the DICOM image: Image image = SimpleITK.ReadImage(fileNames[slice]); origTexWidth = (int)image.GetWidth(); origTexHeight = (int)image.GetHeight(); //int origTexDepth = (int)image.GetDepth (); texWidth = Mathf.NextPowerOfTwo((int)image.GetWidth()); texHeight = Mathf.NextPowerOfTwo((int)image.GetHeight()); texDepth = 1; colors = new Color32[texWidth * texHeight]; int intercept = 0; int slope = 1; try { intercept = Int32.Parse(image.GetMetaData("0028|1052")); slope = Int32.Parse(image.GetMetaData("0028|1053")); } catch { } if (image.GetDimension() != 2 && image.GetDimension() != 3) { throw(new System.Exception("Only 2D and 3D images are currently supported. Dimensions of image: " + image.GetDimension())); } Int64 min = int.MaxValue; Int64 max = int.MinValue; // Copy the image into a colors array: IntPtr bufferPtr; UInt32 numberOfPixels = image.GetWidth() * image.GetHeight(); if (image.GetPixelID() == PixelIDValueEnum.sitkUInt16) { bufferPtr = image.GetBufferAsUInt16(); Int16[] colorsTmp = new Int16[numberOfPixels]; Marshal.Copy(bufferPtr, colorsTmp, 0, (int)numberOfPixels); int index = 0; //for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight) // && z < origTexDepth ) { UInt16 pixelValue = (UInt16)((colorsTmp [index] - intercept) / slope); colors [x + y * texWidth] = F2C(pixelValue); if (pixelValue > max) { max = pixelValue; } if (pixelValue < min) { min = pixelValue; } index++; } } } } else if (image.GetPixelID() == PixelIDValueEnum.sitkInt16) { bufferPtr = image.GetBufferAsInt16(); Int16[] colorsTmp = new Int16[numberOfPixels]; Marshal.Copy(bufferPtr, colorsTmp, 0, (int)numberOfPixels); int index = 0; //for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight) // && z < origTexDepth ) { UInt16 pixelValue = (UInt16)((colorsTmp [index] - intercept) / slope); colors [x + y * texWidth] = F2C(pixelValue); if (pixelValue > max) { max = pixelValue; } if (pixelValue < min) { min = pixelValue; } index++; } } } } else if (image.GetPixelID() == PixelIDValueEnum.sitkInt32) { bufferPtr = image.GetBufferAsInt32(); Int32[] colorsTmp = new Int32[numberOfPixels]; Marshal.Copy(bufferPtr, colorsTmp, 0, (int)numberOfPixels); int index = 0; //for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight) // && z < origTexDepth ) { UInt32 pixelValue = (UInt32)((colorsTmp [index] - intercept) / slope); colors [x + y * texWidth] = F2C(pixelValue); if (pixelValue > max) { max = (Int64)pixelValue; } if (pixelValue < min) { min = (Int64)pixelValue; } index++; } } } } else { throw(new System.Exception("Unsupported pixel format: " + image.GetPixelID())); } // If the DICOM header did not contain info about the minimum/maximum values and no one // has manually set them yet, set the min/max values found for this slice: if (!seriesInfo.foundMinMaxPixelValues) { seriesInfo.setMinMaxPixelValues((int)min, (int)max); } // Make the loaded image accessable from elsewhere: this.image = image; }
public VectorString getHttpHeaders() { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Provider_getHttpHeaders(swigCPtr), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); return ret; }
public DICOM2D(DICOMSeries seriesInfo, int slice) : base(seriesInfo) { dimensions = 2; slice = Mathf.Clamp(slice, 0, seriesInfo.filenames.Count - 1); this.slice = slice; VectorString fileNames = seriesInfo.filenames; // Read the DICOM image: image = SimpleITK.ReadImage(fileNames[slice]); loadImageData(image); VectorDouble o1 = image.GetOrigin(); if (o1.Count < 3) { throw(new System.Exception("Invalid origins found in first image.")); } origin = new Vector3((float)o1 [0], (float)o1 [1], (float)o1 [2]); // Load the direction cosines: // ITK stores the direction cosines in a matrix with row-major-ordering. The weird indexing is because // we need the first and second column (0,3,6 for X and 1,4,7 for Y) VectorDouble direction = image.GetDirection(); if (direction.Count < 6) { throw(new System.Exception("Invalid direction cosines found in images.")); } directionCosineX = new Vector3((float)direction [0], (float)direction [3], (float)direction [6]); directionCosineY = new Vector3((float)direction [1], (float)direction [4], (float)direction [7]); sliceNormal = Vector3.Cross(directionCosineX, directionCosineY); // Calculate which direction the normal is facing to determine the orienation (Transverse, // Coronal or Saggital). float absX = Mathf.Abs(sliceNormal.x); float absY = Mathf.Abs(sliceNormal.y); float absZ = Mathf.Abs(sliceNormal.z); if (absX > absY && absX > absZ) { sliceOrientation = SliceOrientation.Saggital; } else if (absY > absX && absY > absZ) { sliceOrientation = SliceOrientation.Coronal; } else if (absZ > absX && absZ > absY) { sliceOrientation = SliceOrientation.Transverse; } else { sliceOrientation = SliceOrientation.Unknown; } // Load the pixel spacing: // NOTE: It seems that the the first value is the spacing between rows (i.e. y direction), // the second value is the spacing between columns (i.e. x direction). // I was not able to verify this so far, since all test dicoms we had have the same spacing in // x and y direction... VectorDouble spacing = image.GetSpacing(); if (spacing.Count < 2) { throw(new System.Exception("Invalid pixel spacing found in images.")); } pixelSpacing = new Vector2((float)spacing [1], (float)spacing [0]); // Generate the transformation matrices which can later be used to translate pixels to // 3D positions and vice versa. setupTransformationMatrices(); }
public VectorString getValues(string propertyName) { VectorString ret = new VectorString(FiftyOneDegreesPatternV3PINVOKE.Match_getValues__SWIG_0(swigCPtr, propertyName), true); if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); return ret; }
public VectorString getValues(int propertyIndex) { VectorString ret = new VectorString(FiftyOneDegreesTrieV3PINVOKE.Match_getValues__SWIG_2(swigCPtr, propertyIndex), true); if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); return ret; }
public VectorString getAvailableProperties() { VectorString ret = new VectorString(FiftyOneDegreesPatternV3PINVOKE.Provider_getAvailableProperties(swigCPtr), true); if (FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesPatternV3PINVOKE.SWIGPendingException.Retrieve(); return ret; }
public void UpdateTransformValues() { try { PositionText = new VectorString(Piece.transform.position); RotationText = new VectorString(Piece.transform.eulerAngles); ScaleText = new VectorString(Piece.transform.localScale); } catch { } }
public void UpdateTransformValues() { try { switch (elist[editmode]) { case "Position": PositionText = new VectorString(RB.BC[indexBC].PosCurve[selectedFrame].Value); break; case "Rotation": PositionText = new VectorString(RB.BC[indexBC].RotCurve[selectedFrame].Value.eulerAngles); break; case "Scale": PositionText = new VectorString(RB.BC[indexBC].ScaleCurve[selectedFrame].Value); break; } } catch { } }
/*! Load the entire series (i.e. the entire volume). * Unlike loadImageData(), this function does not create a colors array or texture. To * access volume data, simply get the image (DICOM.image) and read pixel values from it. */ private void loadVolumeData() { // Get all file names for the series: VectorString fileNames = seriesInfo.filenames; // Create a reader which will read the whole series: ImageSeriesReader reader = new ImageSeriesReader(); reader.SetFileNames(fileNames); // Load the entire image into a series: Image image = reader.Execute(); origTexWidth = (int)image.GetWidth(); origTexHeight = (int)image.GetHeight(); origTexDepth = (int)image.GetDepth(); texWidth = Mathf.NextPowerOfTwo((int)image.GetWidth()); texHeight = Mathf.NextPowerOfTwo((int)image.GetHeight()); texDepth = Mathf.NextPowerOfTwo((int)image.GetDepth()); texPaddingWidth = texWidth - origTexWidth; texPaddingHeight = texHeight - origTexHeight; texPaddingDepth = texDepth - origTexDepth; Debug.Log("Original texture dimensions: " + origTexWidth + " " + origTexHeight + " " + origTexDepth); Debug.Log("Texture dimensions: " + texWidth + " " + texHeight + " " + texDepth); colors = new Color32[texWidth * texHeight * texDepth]; int intercept = 0; int slope = 1; try { intercept = Int32.Parse(image.GetMetaData("0028|1052")); slope = Int32.Parse(image.GetMetaData("0028|1053")); } catch { } Debug.Log("Slope: " + slope + " Intercept: " + intercept); if (image.GetDimension() != 3) { throw(new System.Exception("Cannot load volume: Image needs to be 3D. Dimensions of image: " + image.GetDimension())); } histogram = new Histogram(); UInt32 min = UInt32.MaxValue; UInt32 max = UInt32.MinValue; Debug.Log("Pixel format: " + image.GetPixelID()); // Copy the image into a colors array: if (image.GetPixelID() == PixelIDValueEnum.sitkUInt16) { IntPtr bufferPtr = image.GetBufferAsUInt16(); unsafe { UInt16 *ptr = (UInt16 *)bufferPtr.ToPointer(); int consecutiveIndex = 0; for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight && z < origTexDepth) { long jumpingIndex = x + y * texWidth + z * texWidth * texHeight; UInt32 pixelValue = (UInt32)((UInt16)ptr [consecutiveIndex]); colors [jumpingIndex] = F2C(pixelValue); if (pixelValue > max) { max = pixelValue; } if (pixelValue < min) { min = pixelValue; } histogram.addValue(pixelValue); consecutiveIndex++; } } } } } } else if (image.GetPixelID() == PixelIDValueEnum.sitkInt16) { IntPtr bufferPtr = image.GetBufferAsInt16(); unsafe { Int16 *ptr = (Int16 *)bufferPtr.ToPointer(); int consecutiveIndex = 0; for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight && z < origTexDepth) { long jumpingIndex = x + y * texWidth + z * texWidth * texHeight; UInt32 pixelValue = (UInt32)((Int16)ptr[consecutiveIndex] + Int16.MaxValue); colors [jumpingIndex] = F2C(pixelValue); if (pixelValue > max) { max = pixelValue; } if (pixelValue < min) { min = pixelValue; } histogram.addValue(pixelValue); consecutiveIndex++; } } } } } } else if (image.GetPixelID() == PixelIDValueEnum.sitkInt32) { IntPtr bufferPtr = image.GetBufferAsInt32(); unsafe { Int32 *ptr = (Int32 *)bufferPtr.ToPointer(); int consecutiveIndex = 0; for (UInt32 z = 0; z < texDepth; z++) { for (UInt32 y = 0; y < texHeight; y++) { for (UInt32 x = 0; x < texWidth; x++) { if (x < origTexWidth && y < origTexHeight && z < origTexDepth) { long jumpingIndex = x + y * texWidth + z * texWidth * texHeight; // TODO: To move from Int32 to UInt32 range, we should add Int32.MaxValue?! // However, when we do this, UInt32 pixelValue = (UInt32)((Int32)ptr[consecutiveIndex]) + (UInt32)Int16.MaxValue; colors [jumpingIndex] = F2C(pixelValue); if (pixelValue > max) { max = pixelValue; } if (pixelValue < min) { min = pixelValue; } histogram.addValue(pixelValue); consecutiveIndex++; } } } } } } else { throw(new System.Exception("Unsupported pixel format: " + image.GetPixelID())); } /*IntPtr bufferPtr; * UInt32 numberOfPixels = image.GetWidth () * image.GetHeight () * image.GetDepth(); * if (image.GetPixelID () == PixelIDValueEnum.sitkUInt16) { * bufferPtr = image.GetBufferAsUInt16 (); * * UInt16[] colorsTmp = new UInt16[ numberOfPixels ]; * Int16[] tmp = new Int16[ numberOfPixels ]; * Marshal.Copy( bufferPtr, tmp, 0, (int)numberOfPixels ); * System.Buffer.BlockCopy (tmp, 0, colorsTmp, 0, (int)numberOfPixels); * * int index = 0; * //for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 y = 0; y < texHeight; y++) { * for (UInt32 x = 0; x < texWidth; x++) { * //long consecutiveIndex = (texWidth-1-x) + y*texWidth + z*texWidth*texHeight; * long consecutiveIndex = x + y * texWidth + z*texWidth*texHeight; * if (x < origTexWidth && y < origTexHeight && z < origTexDepth) { * UInt16 pixelValue = (UInt16)((colorsTmp [index] - intercept) / slope); * colors [consecutiveIndex] = F2C (pixelValue); * * if (pixelValue > max) * max = pixelValue; * if (pixelValue < min) * min = pixelValue; * * histogram.addValue (pixelValue); * * index++; * } * } * } * } * } else if ( image.GetPixelID() == PixelIDValueEnum.sitkInt16 ) { * bufferPtr = image.GetBufferAsInt16 (); * * Int16[] colorsTmp = new Int16[ numberOfPixels ]; * Marshal.Copy( bufferPtr, colorsTmp, 0, (int)numberOfPixels ); * * int index = 0; * //for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 y = 0; y < texHeight; y++) { * for (UInt32 x = 0; x < texWidth; x++) { * //long consecutiveIndex = (texWidth-1-x) + y*texWidth + z*texWidth*texHeight; * long consecutiveIndex = x + y * texWidth + z*texWidth*texHeight; * if (x < origTexWidth && y < origTexHeight && z < origTexDepth ) * { * //Int16 pixelValueInt16 = (Int16)((colorsTmp [index] - intercept) / slope); * //UInt32 pixelValue = (UInt32)((int)pixelValueInt16 + 32768); * * UInt16 pixelValue = (UInt16)((colorsTmp [index] - intercept) / slope); * colors [ consecutiveIndex] = F2C(pixelValue); * * if (pixelValue > max) * max = pixelValue; * if (pixelValue < min) * min = pixelValue; * * histogram.addValue (pixelValue); * * index++; * } * } * } * } * } else if ( image.GetPixelID() == PixelIDValueEnum.sitkInt32 ) { * bufferPtr = image.GetBufferAsInt32 (); * * Int32[] colorsTmp = new Int32[ numberOfPixels ]; * Marshal.Copy( bufferPtr, colorsTmp, 0, (int)numberOfPixels ); * * int index = 0; * //for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 z = 0; z < texDepth; z++) { * for (UInt32 y = 0; y < texHeight; y++) { * for (UInt32 x = 0; x < texWidth; x++) { * //long consecutiveIndex = (texWidth-1-x) + y*texWidth + z*texWidth*texHeight; * long consecutiveIndex = x + y * texWidth + z*texWidth*texHeight; * if (x < origTexWidth && y < origTexHeight && z < origTexDepth) { * Int32 pixelValueInt32 = (Int32)((colorsTmp [index] - intercept) / slope); * * UInt32 pixelValue = (UInt32)((Int64)pixelValueInt32 + Int32.MaxValue); * colors [ consecutiveIndex ] = F2C(pixelValue); * * if (pixelValue > max) * max = pixelValue; * if (pixelValue < min) * min = pixelValue; * * histogram.addValue (pixelValue); * * index++; * } * } * } * } * } else { * throw(new System.Exception ("Unsupported pixel format: " + image.GetPixelID())); * }*/ // Manually set the min and max values, because we just caculated them for the whole volume and // can thus be sure that we have the correct values: seriesInfo.setMinMaxPixelValues(min, max); histogram.setMinMaxPixelValues(min, max); // Make the loaded image accessable from elsewhere: this.image = image; Debug.Log("Loaded."); }
public Provider(string fileName, VectorString propertiesArray) : this(FiftyOneDegreesTrieV3PINVOKE.new_Provider__SWIG_2(fileName, VectorString.getCPtr(propertiesArray)), true) { if (FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Pending) throw FiftyOneDegreesTrieV3PINVOKE.SWIGPendingException.Retrieve(); }