public static DicomFile GenerateDicomFile()

in tools/scale-testing/Common/DicomImageGenerator.cs [64:129]


        public static DicomFile GenerateDicomFile(
            string studyInstanceUid,
            string seriesInstanceUid,
            string sopInstanceUid,
            string sopClassUid,
            int rows,
            int cols,
            TestFileBitDepth bitDepth,
            string transferSyntax,
            bool encode,
            int frames = 1,
            string photometricInterpretation = null)
        {
            DicomTransferSyntax initialTs = DicomTransferSyntax.ExplicitVRLittleEndian;

            if (!encode)
            {
                initialTs = DicomTransferSyntax.Parse(transferSyntax);
            }

            var rand = new Random();

            var dicomFile = new DicomFile(
                new DicomDataset(initialTs)
                {
                    { DicomTag.StudyInstanceUID, studyInstanceUid ?? TestUidGenerator.Generate() },
                    { DicomTag.SeriesInstanceUID, seriesInstanceUid ?? TestUidGenerator.Generate() },
                    { DicomTag.SOPInstanceUID, sopInstanceUid ?? TestUidGenerator.Generate() },
                    { DicomTag.SOPClassUID, sopClassUid ?? TestUidGenerator.Generate() },
                    { DicomTag.Rows, (ushort)rows },
                    { DicomTag.Columns, (ushort)cols },
                    { DicomTag.PhotometricInterpretation, photometricInterpretation ?? PhotometricInterpretation.Monochrome2.Value },
                    { DicomTag.BitsAllocated, (ushort)bitDepth },
                    { DicomTag.WindowWidth, ((bitDepth == TestFileBitDepth.EightBit) ? "256" : "65536") },
                    { DicomTag.WindowCenter, ((bitDepth == TestFileBitDepth.EightBit) ? "128" : "32768") },
                    { DicomTag.AccessionNumber, rand.Next(11111111, 19999999) },
                    { DicomTag.PatientID, TestUidGenerator.Generate() },
                });

            var pixelData = DicomPixelData.Create(dicomFile.Dataset, true);
            pixelData.SamplesPerPixel = 1;
            pixelData.BitsStored = (ushort)bitDepth;
            pixelData.HighBit = (ushort)(bitDepth - 1);
            pixelData.PixelRepresentation = PixelRepresentation.Unsigned;

            for (int i = 0; i < frames; i++)
            {
                var buffer = new MemoryByteBuffer(
                    (bitDepth == TestFileBitDepth.SixteenBit)
                        ? GetBytesFor16BitImage(rows, cols, i)
                        : GetBytesFor8BitImage(rows, cols, i));

                pixelData.AddFrame(buffer);
            }

            if (encode && transferSyntax != DicomTransferSyntax.ExplicitVRLittleEndian.UID.UID)
            {
                var transcoder =
                    new DicomTranscoder(
                        dicomFile.Dataset.InternalTransferSyntax,
                        DicomTransferSyntax.Parse(transferSyntax));
                dicomFile = transcoder.Transcode(dicomFile);
            }

            return dicomFile;
        }