Пример #1
0
        public static Matrix <UInt16> ConvertStretchImageU16BitToJPG(Matrix <UInt16> CVMat, Double LowerPercen, Double UpperPercen)
        {
            int DataLength = CVMat.Rows * CVMat.Cols;

            UInt16[] Data = new UInt16[DataLength];
            CVMat.Mat.CopyTo(Data);

            int LowerPosition = Convert.ToInt32(DataLength * LowerPercen / 100);
            int UpperPosition = Convert.ToInt32(DataLength * UpperPercen / 100);

            List <UInt16> DataList = Data.ToList();

            DataList.Sort();

            UInt16 LowerValue = DataList[LowerPosition == DataLength ? LowerPosition - 1 : LowerPosition];
            UInt16 UpperValue = DataList[UpperPosition == DataLength ? UpperPosition - 1 : UpperPosition];

            Double A = (Double)ushort.MinValue;
            Double B = (Double)ushort.MaxValue;
            Double C = (Double)LowerValue;
            Double D = (Double)UpperValue;

            Matrix <UInt16> NewImg = (CVMat - C) * ((B - A) / (D - C)) + A;

            NewImg = NewImg / 257;
            return(NewImg);
        }
        public override void Read(BinaryReader b)
        {
            base.Read(b);
            NumExtVertices = this.DataSize / sizeof(UInt16);
            Source         = new UInt16[NumExtVertices];
            for (int i = 0; i < NumExtVertices; i++)
            {
                Source[i] = b.ReadUInt16();
            }
            // Add to SkinningInfo
            SkinningInfo skin = GetSkinningInfo();

            skin.Ext2IntMap         = Source.ToList();
            skin.HasIntToExtMapping = true;
        }