示例#1
0
        public void _SwapSides()
        {
            oMatrix temp = LLL;

            LLL = RRR;
            RRR = temp;
        }
示例#2
0
        public void _ExportRawDataTiff(oMatrix input, string filename)
        {
            int width  = input.Width();
            int height = input.Height();

            using (Tiff output = Tiff.Open(@filename, "w"))
            {
                output.SetField(TiffTag.IMAGEWIDTH, width);
                output.SetField(TiffTag.IMAGELENGTH, height);
                output.SetField(TiffTag.SAMPLESPERPIXEL, 1);
                output.SetField(TiffTag.BITSPERSAMPLE, 16);
                output.SetField(TiffTag.ORIENTATION, BitMiracle.LibTiff.Classic.Orientation.TOPLEFT);
                output.SetField(TiffTag.XRESOLUTION, 72);
                output.SetField(TiffTag.YRESOLUTION, 72);
                output.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.CENTIMETER);
                output.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
                output.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
                output.SetField(TiffTag.COMPRESSION, Compression.LZW);
                output.SetField(TiffTag.ROWSPERSTRIP, height);
                output.SetField(TiffTag.FILLORDER, FillOrder.MSB2LSB);
                byte[] bytebuffer = new byte[width * 16 / 8];
                double rawValue;
                for (int yyy = 0; yyy < height; yyy++)
                {
                    for (int xxx = 0; xxx < width; xxx++)
                    {
                        rawValue                   = input.GetValue(xxx, yyy);
                        bytebuffer[xxx << 1]       = (byte)(rawValue % 256);
                        bytebuffer[(xxx << 1) + 1] = (byte)(rawValue / 256);
                    }
                    output.WriteScanline(bytebuffer, yyy);
                }
            }
        }
示例#3
0
        public void _ExportAdobeConverted(oMatrix input, string filename)
        {
            int         width   = input.Width();
            int         height  = input.Height();
            List <byte> rawdata = new List <byte>();

            for (int yyy = 0; yyy < height; yyy++)
            {
                for (int xxx = 0; xxx < width; xxx++)
                {
                    rawdata.Add(Convert.ToByte((Convert.ToInt32(input.GetValue(xxx, yyy))) % 256));
                    rawdata.Add(Convert.ToByte((Convert.ToInt32(input.GetValue(xxx, yyy))) / 256));
                }
            }

            byte[] output = rawdata.ToArray();

            using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
            {
                int    filelength = (int)(new System.IO.FileInfo(filename).Length);
                int    datalength = rawdata.Count;
                int    start_addr = filelength - datalength;
                byte[] bytebuffer = reader.ReadBytes(filelength);
                Console.WriteLine();
                for (int i = start_addr; i < filelength; i++)
                {
                    bytebuffer[i] = output[i - start_addr];
                }
                Console.WriteLine();
                _byteArrayWriter(bytebuffer, filename, "_corrected");
                Console.WriteLine();
            }
        }
示例#4
0
        public void _ExportFPM(oMatrix input, string filename)
        {
            StringBuilder sb = new StringBuilder();
            int           temp;
            int           height = input.Height();
            int           width  = input.Width();

            for (int yyy = 0; yyy < height; yyy++)
            {
                for (int xxx = 0; xxx < width; xxx++)
                {
                    temp = input.GetValue(xxx, yyy);
                    if (temp <= 0)
                    {
                        sb.Append(xxx + " \t " + yyy + "\n");
                    }
                }
            }
            System.IO.File.WriteAllText(@filename, sb.ToString());
        }
示例#5
0
        public ushort[,] _Collector2(ushort[,] data, ushort[,] map, int radius)
        {
            int width  = data.GetLength(0);
            int height = data.GetLength(1);

            ushort[,] output = data;

            List <InterpolatedUnit>[,] allValue = new List <InterpolatedUnit> [width, height];

            for (int xxx = 0; xxx < width; xxx++)
            {
                for (int yyy = 0; yyy < height; yyy++)
                {
                    List <InterpolatedUnit> results = new List <InterpolatedUnit>();
                    if (map[xxx, yyy] == 0)
                    {
                        if (yyy - radius >= 0 && yyy + radius < height && xxx - radius >= 0 && xxx + radius < width)
                        {
                            int size = (radius * 2) + 1;

                            oMatrix subData = new oMatrix(data);
                            subData = subData.Submatrix(xxx - radius, yyy - radius, size, size);

                            //data.Submatrix(yyy - radius, xxx - radius, size, size);

                            double[] tempData = new double[size];
                            double[] places   = new double[tempData.Length];
                            for (int i = 0; i < places.Length; i++)
                            {
                                places[i] = i;
                            }

                            int orders = 2;

                            tempData = subData.ReturnRowAsDoubleArray(radius);
                            for (int i = 1; i <= orders; i++)
                            {
                                results.Add(_Fitter(tempData, places, i));
                            }

                            /*tempData = subData.ReturnColumnAsDoubleArray(radius);
                             * for (int i = 1; i <= orders; i++)
                             * {
                             *  results.Add(_Fitter(tempData, places, i));
                             * }*/

                            /*tempData = subData.ReturnDiagonalAsDoubleArray1();
                             * for (int i = 1; i <= orders; i++)
                             * {
                             *  results.Add(_Fitter(tempData, places, i));
                             * }
                             *
                             * tempData = subData.ReturnDiagonalAsDoubleArray2();
                             * for (int i = 1; i <= orders; i++)
                             * {
                             *  results.Add(_Fitter(tempData, places, i));
                             * }*/
                        }

                        else
                        {
                            //BORDER, ONLY VERTICAL OR HORIZONTAL
                        }
                    }
                    else
                    {
                        //Nothing to do
                    }
                    allValue[xxx, yyy] = results;
                }
            }
            for (int xxx = 0; xxx < width; xxx++)
            {
                for (int yyy = 0; yyy < height; yyy++)
                {
                    if (allValue[xxx, yyy].Count != 0)
                    {
                        InterpolatedUnit bestGoodness = new InterpolatedUnit {
                            goodnessOfFit = 99999999999999
                        };
                        List <InterpolatedUnit> temp3 = allValue[xxx, yyy];
                        for (int i = 0; i < temp3.Count; i++)
                        {
                            if (temp3[i].goodnessOfFit <= bestGoodness.goodnessOfFit)
                            {
                                bestGoodness = temp3[i];
                            }
                        }
                        output[xxx, yyy] = (ushort)bestGoodness.value;
                    }
                }
            }

            return(output);
        }
示例#6
0
 public BP_Data()
 {
     LLL = new oMatrix(new ushort[0, 0]);
     RRR = new oMatrix(new ushort[0, 0]);
 }