Exemple #1
0
        public override IType[] Run(Dictionary<RequestType, object> requestedData, BaseOption[] options, IType[] inputArgs)
        {
            int blockWidth = (int) options[0].Value;
            int blockHeight = (int) options[1].Value;
            Xwt.Size blockSize = new Xwt.Size(blockWidth, blockHeight);

            TScan scan = inputArgs[0] as TScan;

            int width = (int) scan.Size.Width;
            int height = (int) scan.Size.Height;

            float[] inputData = scan.Data;
            for (int y = 0; y < height-blockHeight; y += blockHeight) {
                for (int x = 0; x < width-blockWidth; x+= blockWidth) {
                    float[] data = new float[blockWidth*blockHeight];

                    bool empty = true;
                    for (int i = 0; i < blockWidth; i++) {
                        for (int j = 0; j < blockHeight; j++) {
                            float value = inputData[x + i + ((y + j) * width)];
                            data[i + (j * blockWidth)] = value;

                            if (value > 0.0) {
                                empty = false;
                            }
                        }
                    }

                    if (!empty) {
                        TScan block = new TScan(data, blockSize, scan.IsMultipleAccessModeOn);
                        Yield(new IType[] { block }, null);
                    }
                }
            }

            return null;
        }
Exemple #2
0
        public override IType[] Run(Dictionary<RequestType, object> requestedData, BaseOption[] options, IType[] inputArgs)
        {
            ScanCollection scans = requestedData[RequestType.ScanCollection] as ScanCollection;
            int size = scans.Count;

            bool maskedOnly = (bool) options[0].Value;

            int i = 0;
            foreach (BaseScan scan in scans) {
                if (IsCanceled) {
                    break;
                }

                IType[] data = new IType[1];
                if ((maskedOnly && scan.HasMask) || !maskedOnly) {
                    if (scan.AvailableScanTypes().Contains(scanTypeComboBox.Value)) {
                        data[0] =
                            new TScan(scan, scanTypeComboBox.Value.ToString(), maskedOnly: maskedOnly).Preload();

                        Yield(data, scan);
                    }
                }

                i++;

                SetProgress((i * 100) / size);
            }

            return null;
        }