Beispiel #1
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            int tam = m_Bitmap.Width * m_Bitmap.Height;

            float gamma_ = Int32.Parse(gamma.Text);
            gamma_ = gamma_/100;

            a = (FormPrincipal)MdiParent;
            a_Bitmap = new Bitmap(m_Bitmap.Width, m_Bitmap.Height);

            for (int i = 0; i < m_Bitmap.Width; i++)
            {
                for (int j = 0; j < m_Bitmap.Height; j++)
                {

                    nVal = (int)(Math.Pow((m_Bitmap.GetPixel(i,j).R / 255.0), gamma_) * 255);

                    a_Bitmap.SetPixel(i, j, Color.FromArgb(255, nVal, nVal, nVal));
                }
            }
            FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);
            a.Imagenes.Add(subImagen);
            a.Imagenes[a.lastid].MdiParent = this.MdiParent;
            a.Imagenes[a.lastid].Show();
            a.lastid++;
        }
Beispiel #2
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            a = (FormPrincipal)MdiParent;

            // Get the angle.
            angle = Int32.Parse(grados.Text);

            // Rotate.
            a_Bitmap = RotateBitmap(m_Bitmap, angle);

            // Display the result.
            FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);

            int wid = subImagen.pictureBox1.Right + subImagen.pictureBox1.Left;
            int hgt = subImagen.pictureBox1.Bottom + subImagen.pictureBox1.Left;
            this.ClientSize = new Size(
                Math.Max(wid, this.ClientSize.Width),
                Math.Max(hgt, this.ClientSize.Height));

            a.Imagenes.Add(subImagen);
            a.Imagenes[a.lastid].MdiParent = this.MdiParent;
            a.Imagenes[a.lastid].Show();
            a.lastid++;
            // Size the form to fit.
        }
Beispiel #3
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            a = (FormPrincipal)MdiParent;
            float nalto, nancho;

            if (percen)
            {
                nalto = Int32.Parse(alto.Text);
                nalto = (float)nalto / 100 * m_Bitmap.Height;
                nalto = (int)nalto;
                nancho = Int32.Parse(ancho.Text);
                nancho = (float)nancho / 100 * m_Bitmap.Width;
                nancho = (int)nancho;
            }
            else
            {
                nalto = Int32.Parse(alto.Text);
                nancho = Int32.Parse(ancho.Text);
            }

            a_Bitmap = new Bitmap((int)nancho, (int)nalto);

            float a1 = ((float)nancho) / (m_Bitmap.Width - 1);
            float b1 = ((float)nalto) / (m_Bitmap.Height - 1);
            for (int i = 0; i < nancho; i++)
            {
                for (int j = 0; j < nalto; j++)
                {
                    float x = ((float)i) / a1;
                    float y = ((float)j) / b1;

                    int minX = (int)Math.Floor(x);
                    int minY = (int)Math.Floor(y);
                    int maxX = minX + 1;
                    int maxY = minY + 1;

                    double p = Math.Abs(x - minX);
                    double q = Math.Abs(y - minY);

                    Color pA = m_Bitmap.GetPixel(minX, maxY);
                    Color pB = m_Bitmap.GetPixel(maxX, maxY);
                    Color pC = m_Bitmap.GetPixel(minX, minY);
                    Color pD = m_Bitmap.GetPixel(maxX, minY);

                    int valor = (int)(((float)pC.R) + ((float)(pD.R - pC.R)) * p + ((float)(pA.R - pC.R)) * q + ((float)(pB.R + pC.R - pA.R - pD.R)) * p * q);

                    a_Bitmap.SetPixel(i, j, Color.FromArgb(255,valor,valor,valor));
                }
            }

            FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);
            a.Imagenes.Add(subImagen);
            a.Imagenes[a.lastid].MdiParent = this.MdiParent;
            a.Imagenes[a.lastid].Show();
            a.lastid++;
        }
Beispiel #4
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            a = (FormPrincipal)MdiParent;
            float nalto, nancho;

            if (percen)
            {
                nalto = Int32.Parse(alto.Text);
                nalto = (float)nalto/100 * m_Bitmap.Height;
                nalto = (int)nalto;
                nancho = Int32.Parse(ancho.Text);
                nancho = (float)nancho / 100 * m_Bitmap.Width;
                nancho = (int)nancho;
            }
            else
            {
                nalto = Int32.Parse(alto.Text);
                nancho = Int32.Parse(ancho.Text);
            }
            a_Bitmap = new Bitmap((int)nancho, (int)nalto);

            /*            double x_ratio = m_Bitmap.Width / (double)nancho;
            double y_ratio = m_Bitmap.Height / (double)nalto;
            double px, py; */

            float a1 = ((float)nancho) / (m_Bitmap.Width - 1);
            float b1 = ((float)nalto) / (m_Bitmap.Height - 1);
            float x = 0, y = 0;

            for(int i = 0; i < nancho; i++){
                   for(int j = 0; j < nalto; j++){
                       x = (int)Math.Round((i) / a1);
                       y = (int)Math.Round((j) / b1);

                       a_Bitmap.SetPixel(i, j, m_Bitmap.GetPixel((int)x,(int)y));
                       //colorAux = vecino(newAncho,newAlto,i,j);

                       //outImage.setRGB(i,j,colorAux.getRGB());
                   }
               }
            FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);
            a.Imagenes.Add(subImagen);
            a.Imagenes[a.lastid].MdiParent = this.MdiParent;
            a.Imagenes[a.lastid].Show();
            a.lastid++;
        }
Beispiel #5
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            int tam = m_Bitmap.Width * m_Bitmap.Height;

            for (int i = 0; i < hist.Count(); i++)
                vbrillo += hist[i] * i;

            vbrillo /= tam;

            for (int i = 0; i < hist.Count(); i++)
                vcontraste += hist[i] * (float)Math.Pow(i - vbrillo, 2);

            vcontraste = (float)Math.Sqrt(vcontraste / tam);

            float nbrillo = Int32.Parse(brillo.Text);
            float ncontraste = Int32.Parse(contraste.Text);
            int nVal;

            A = ncontraste / vcontraste;
            B = nbrillo - (A * vbrillo);

            a = (FormPrincipal)MdiParent;
            a_Bitmap = new Bitmap(m_Bitmap.Width, m_Bitmap.Height);

            for (int i = 0; i < m_Bitmap.Width; i++)
            {
                for (int j = 0; j < m_Bitmap.Height; j++)
                {
                    //int nVal = (int)(m_Bitmap.GetPixel(i, j).B + (int)nbrillo);

                    if (A != 0) nVal = ((int)(m_Bitmap.GetPixel(i, j).B * A + B));
                    else nVal= m_Bitmap.GetPixel(i, j).B + (int)B;
                    //red*A+B;
                    if (nVal < 0) nVal = 0;
                    if (nVal > 255) nVal = 255;

                    a_Bitmap.SetPixel(i, j, Color.FromArgb(255, nVal, nVal, nVal));
                }
            }
            FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);
            a.Imagenes.Add(subImagen);
            a.Imagenes[a.lastid].MdiParent = this.MdiParent;
            a.Imagenes[a.lastid].Show();
            a.lastid++;
        }
Beispiel #6
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (select)
            {

                MouseEventArgs me = (MouseEventArgs)e;
                Point coordinates = me.Location;
                if (!ROI)
                {
                    Color valor = m_Bitmap.GetPixel(coordinates.X, coordinates.Y);
                    MessageBox.Show(coordinates + " Valor de gris " + valor.G);
                }

                if (ROI)
                {
                    if (segundo)
                    {
                        int aux = 0, auxi = 0;
                        int temp;
                        cx = coordinates.X;
                        cy = coordinates.Y;
                        if (cpx > cx) { temp = cpx; cpx = cx; cx = temp; }
                        if (cpy > cy) { temp = cpy; cpy = cy; cy = temp; }
                        rectx = cx - cpx;
                        recty = cy - cpy;
                        copia = new Color[rectx * recty];
                        //Size tam = new Size(Math.Abs(cx-cpx),Math.Abs(cy-cpy));
                        a_Bitmap = new Bitmap(rectx, recty);
                        for (int i = cpx; i < cx; i++)
                        {
                            for (int j = cpy; j < cy; j++)
                            {
                                copia[aux] = m_Bitmap.GetPixel(i, j);
                                aux++;
                                //                            a_Bitmap.SetPixel(i,j,copia);
                            }
                        }

                        for (int i = 0; i < rectx; i++)
                        {
                            for (int j = 0; j < recty; j++)
                            {
                                a_Bitmap.SetPixel(i, j, copia[auxi]);
                                auxi++;
                            }
                        }
                        /*FormPrincipal*/
                        a = (FormPrincipal)MdiParent;
                        FormImagen subImagen = new FormImagen(a_Bitmap, a.lastid);
                        a.Imagenes.Add(subImagen);
                        a.Imagenes[a.lastid].MdiParent = this.MdiParent;
                        a.Imagenes[a.lastid].Show();
                        a.lastid++;
                        segundo = !segundo;
                    }
                    else
                    {
                        cpx = coordinates.X;
                        cpy = coordinates.Y;
                        segundo = !segundo;
                        MessageBox.Show("Selecciona el segundo pixel");
                    }

                }
            }
        }
Beispiel #7
0
 private void FormImagen_Activated(object sender, EventArgs e)
 {
     a = (FormPrincipal)MdiParent;
     a.activeid = this.id;
     this.Text = id.ToString();
 }