Beispiel #1
0
        private double[,] Extracted_pso_operation(double[,] hostcolor, double[,] wmcolor, double[,] vtWcolor, Bitmap pic, Bitmap WmPic, Bitmap vwPic, double[,] sWm)
        {
            svd_host      = new svd_operation(pic, hostcolor);
            svd_watermark = new svd_operation(WmPic, wmcolor);
            svd_operation svd_ww = new svd_operation(vwPic, vtWcolor);

            double[,] wmP   = svd_ww.get_w();
            double[,] hostP = svd_host.get_w();
            double[,] newS  = new double[WmPic.Width, WmPic.Height];
            for (int i = 0; i < wmP.GetLength(0); i++)
            {
                for (int j = 0; j < wmP.GetLength(1); j++)
                {
                    newS[i, j] = (wmP[i, j] - hostP[i, j]) / 0.0025;
                }
            }
            double[,] wmU  = svd_watermark.svd.U.ToArray();
            double[,] wmVt = svd_watermark.svd.VT.ToArray();

            double[,] recompo = new double[wmU.GetLength(0), wmU.GetLength(1)];
            recompo           = svd_watermark.perkalian_matrix(wmU, newS);
            recompo           = svd_watermark.perkalian_matrix(recompo, wmVt);

            for (int i = 0; i < recompo.GetLength(0); i++)
            {
                for (int j = 0; j < recompo.GetLength(1); j++)
                {
                    hostcolor[i, j] = recompo[i, j];
                }
            }
            return(hostcolor);
        }
Beispiel #2
0
        private double[,] svd_pso_operation(double[,] hostcolor, double[,] wmcolor, Bitmap pic, Bitmap WmPic, double[,] vt, string color)
        {
            svd_host      = new svd_operation(pic, hostcolor);
            svd_watermark = new svd_operation(WmPic, wmcolor);
            vt            = svd_watermark.getP();
            for (int i = 0; i < vt.GetLength(0); i++)
            {
                for (int j = 0; j < vt.GetLength(1); j++)
                {
                    vt[i, j] *= 0.0025;
                }
            }

            double[,] snew = new double[vt.GetLength(0), vt.GetLength(1)];
            snew           = svd_host.getnew_W(vt);
            if (sWmRed == null)
            {
                sWmRed = new double[snew.GetLength(0), snew.GetLength(1)];
            }

            if (swGreen == null)
            {
                swGreen = new double[snew.GetLength(0), snew.GetLength(1)];
            }

            if (swBlue == null)
            {
                swBlue = new double[snew.GetLength(0), snew.GetLength(1)];
            }

            for (int i = 0; i < snew.GetLength(0); i++)
            {
                for (int j = 0; j < snew.GetLength(1); j++)
                {
                    if (color.Equals("red"))
                    {
                        sWmRed[i, j] = snew[i, j];
                    }
                    else if (color.Equals("green"))
                    {
                        swGreen[i, j] = snew[i, j];
                    }
                    else if (color.Equals("blue"))
                    {
                        swBlue[i, j] = snew[i, j];
                    }
                }
            }
            double[,] host_u  = svd_host.svd.U.ToArray();
            double[,] host_vt = svd_host.svd.VT.ToArray();
            double[,] host_w  = svd_host.get_w();
            double[,] recompo = new double[host_u.GetLength(0), host_u.GetLength(1)];
            recompo           = svd_host.perkalian_matrix(host_u, snew);
            recompo           = svd_host.perkalian_matrix(recompo, host_vt);
            for (int i = 0; i < recompo.GetLength(0); i++)
            {
                for (int j = 0; j < recompo.GetLength(1); j++)
                {
                    hostcolor[i, j] = recompo[i, j];
                }
            }
            return(hostcolor);
        }