Пример #1
0
        static public HSIComplexImg Img2HSIComplexImg(Bitmap Source)
        {
            int           Width = Source.Width, Height = Source.Height;
            BitmapData    SourceData = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            HSIComplexImg Result     = new HSIComplexImg(Width, Height);
            BGR           BGRTmp     = new BGR();
            HSI           HSITmp;
            byte *        SourcePointer = (byte *)SourceData.Scan0.ToPointer();
            int           X, Y, T;

            for (Y = 0; Y < Height; ++Y)
            {
                for (X = 0; X < Width; ++X)
                {
                    for (T = 0; T < 3; ++T)
                    {
                        BGRTmp[T] = SourcePointer[0];
                        ++SourcePointer;
                    }
                    ++SourcePointer;
                    HSITmp          = BGRTmp.ToHSI();
                    Result[0][Y, X] = new AMComplex(HSITmp.H, 0);
                    Result[1][Y, X] = new AMComplex(HSITmp.S, 0);
                    Result[2][Y, X] = new AMComplex(HSITmp.I, 0);
                }
            }
            Source.UnlockBits(SourceData);
            return(Result);
        }
Пример #2
0
        static public HSIComplexImg BGR2HSI(BGRComplexImg Source)
        {
            HSIComplexImg Result = new HSIComplexImg(Source.Width, Source.Height);
            BGR           TmpBGR = new BGR();
            HSI           TmpHSI = null;
            int           X, Y;

            for (Y = 0; Y < Source.Height; ++Y)
            {
                for (X = 0; X < Source.Width; ++X)
                {
                    TmpBGR.R          = DoubleToByte(Source.R[Y, X].Re);
                    TmpBGR.B          = DoubleToByte(Source.B[Y, X].Re);
                    TmpBGR.G          = DoubleToByte(Source.G[Y, X].Re);
                    TmpHSI            = TmpBGR.ToHSI();
                    Result.H[Y, X].Re = TmpHSI.H;
                    Result.S[Y, X].Re = TmpHSI.S;
                    Result.I[Y, X].Re = TmpHSI.I;
                }
            }
            return(Result);
        }